Docker-compose 1

欲控制多組containers,可以使用現有manage multi-processes軟體如:Supervisor…等
但也許會出現一些問題 http://stackoverflow.com/questions/30034813/best-way-to-manage-docker-containers-with-supervisord

Docker官方提供Compose來執行控制多組containers

https://github.com/docker/compose/

Compose is a tool for defining and running multi-container Docker applications.

安裝…

1
2
3
$ wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
$ sudo easy_install pip
$ sudo pip install -U docker-compose

docker run 轉成 docker-compose yaml 語法…

1
2
3
4
5
6
7
8
9
10
11
12
13
# docker run -itd --name jeff --restart=always -p 9080:9080  -v /home/jeff/code/:/home/code centos

# docker-compose.yml
build:
container_name: jeff
image: centos
ports:
- 9080:9080
volumes:
- /home/jeff/code/:/home/code
restart: always
stdin_open: true
tty: true

同一目錄下執行…


docker-compose up -d

 

Check…


docker inspect jeff