Jav*_*ser 13 containers docker docker-compose
我有两个容器映像,并使用“ docker-compose up -d ”进行 compose 和运行 docker 。这很好用。我想在另一个端口(例如 8081)中运行相同的容器映像。我们可以将端口映射作为命令行参数 docker-compose up -port novnc :8081:8080 传递吗?如何将端口映射动态传递给 docker-compose up 命令?
version: '2'
services:
ide:
image: myApp
image: myImage:latest
environment:
- DISPLAY=novnc:0.0
depends_on:
- novnc
networks:
- x11
novnc:
image: myImageTwo:latest
environment:
- DISPLAY_WIDTH=1600
- DISPLAY_HEIGHT=968
ports:
- "8080:8080"
networks:
- x11
networks:
x11:
Run Code Online (Sandbox Code Playgroud)
在 docker-compose.yml 中使用 ${VAR}
例如
version: '2'
services:
apache:
image: httpd:2.4
volumes:
- .:/usr/local/apache2/htdocs/
ports:
- ${APP_PORT}:80
Run Code Online (Sandbox Code Playgroud)
然后使用环境变量:
$ export APP_PORT=8080
$ docker-compose up
Run Code Online (Sandbox Code Playgroud)
或内联版本:
$ APP_PORT=8080 docker-compose up
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10028 次 |
| 最近记录: |