1、新建一个文件夹,里面创建文件 docker-compose.yml
2、编辑 docker-compose.yml 文件,保存以下内容
# docker volume
#docker run -d --name dbdata -h dbdata -v /wwwroot:/home/vagrant/wwwroot -v /Downloads:/home/vagrant/Downloads -v /wwwroot/web/dockerfile/nginx-php/conf.d:/etc/nginx/conf.d ubuntu:12.04
#先运行上面docker run 命令,建立volume,供下面容器使用
imysql55:
p_w_picpath: mytest/mysql-5.5
hostname: mysql-5-5
volumes_from:
- dbdata
expose:
- "3306"
ports:
- "3306:3306"
iredis22:
p_w_picpath: mytest/redis-2.2
hostname: redis-2-2
volumes_from:
- dbdata
expose:
- "6379"
ports:
- "6379:6379"
iphp53:
p_w_picpath: mytest/php
hostname: php-5-3
volumes_from:
- dbdata
expose:
- "9000"
links:
- imysql55
- iredis22
iphp56:
p_w_picpath: mytest/php-5.6
hostname: php-5-6
volumes_from:
- dbdata
expose:
- "9000"
links:
- imysql55
- iredis22
inginx:
p_w_picpath: mytest/nginx
hostname: nginx-1-1-9
volumes_from:
- dbdata
ports:
- "80:80"
links:
- imysql55
- iredis22
- iphp53
- iphp56
3、使用命令 docker-compose up -d 生成容器
4、使用命令 docker-compose start 启动容器
其中 p_w_picpath,请参与以下链接
https://github.com/bstdn/dockerfile