service
services:
#服务名称,不可重复
web:
#服务的镜像名称或镜像 ID,如果镜像在本地不存在,Compose 将会尝试拉取这个镜像
image: dockercloud/hello-world
#基于一份 Dockerfile构建镜像,指定 Dockerfile 所在文件夹的路径
#如果你同时指定了 image 和 build 两个标签,那么 Compose 会构建镜像并且把镜像命名为 image 后面的那个名字
#build: /path/to/build/dir
#也可以是相对路径,建议使用
#build: ./dir
#设定上下文根目录,然后以该目录为准指定 Dockerfile,不建议用
build:
context: ../
dockerfile: path/of/Dockerfile
#Dockerfile 中的 ARG 指令,和ENV不同,ARG允许空值
args:
- buildno=
- password=secret
#不建议这种写法
#args:
# buildno: 1
# password: secret
#command 可以覆盖容器启动后默认执行的命令
command: bundle exec thin -p 3000
#也可以写成类似 Dockerfile 中的格式:
# command: [bundle, exec, thin, -p, 3000]
#容器名称,不写则默认为 项目名称_服务名称_序号
container_name: app
#控制容器启动的顺序,先启动 redis 和 db 两个服务,最后才启动 web 服务:
depends_on:
- db