Docker Compose 1.2.0 RC3 發布
Docker Compose 1.2.0 RC3 發布,測試此版本請使用:
curl -L https://github.com/docker/compose/releases/download/1.2.0rc3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
此版本相比 RC1 和 RC2 修復的 bug 如下:
-
When copying a service's configuration with
extends
,image
andbuild
could come into conflict, resulting in an error, as it makes no sense to have both defined. Each now overwrites the other: if a service withimage
defined is extended andbuild
is added, theimage
entry will be removed. -
When copying a service's configuration with
extends
, if both services defined a multi-value option such asports
ordns
, the original value would be completely discarded. They are now concatenated instead. -
When a relative path is supplied to
build
, it is treated as relative to the directory of the configuration file, not the directory thatdocker-compose
is being run in. In the majority of cases, those are the same, but if you use the-f|--file
argument to specify a configuration file in another directory, this is a breaking change.
更多改進內容請看發行說明。
此版本現已提供下載:
Docker Compose 是 Docker 編排服務的一部分,Machine 可以讓用戶在其它平臺快速安裝Docker,Swarm 可以讓 Docker 容器在集群中高效運轉,而 Compose 可以讓用戶在集群中部署分布式應用。簡單的說,Docker Compose 屬于一個“應用層”的服務,用戶可以定義哪個容器組運行哪個應用,它支持動態改變應用,并在需要時擴展。
使用Compose的第一步是使用YAML文件來定義容器應用的狀態:
containers:
web:
build: .
command: python app.py
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
environment:
- PYTHONUNBUFFERED=1
redis:
image: redis:latest
command: redis-server --appendonly yes
上面的YAML文件定義了兩個容器應用,第一個容器運行Python應用,并通過當前目錄的Dockerfile文件構建。第二個容器是從Docker Hub注冊中心的Redis官方倉庫中構建。links指令用來定義依賴,意思是Python應用依賴于Redis應用。
定義完成后,通過下面的命令來啟動應用:
% docker up
簡單吧?通過YAML文件定義的容器應用已經成功啟動起來,啟動過程會按照YAML的配置嚴格運行。Python容器通過Dockerfile自動構建, 同時從注冊中心拉取Redis容器構建。 links指令關注的是Python和Redis容器之間的依賴關系,Redis容器是最先開始構建,緊隨其后的是Python容器。
介紹內容來自 DockerOne