Docker的那些事兒—如何安裝docker-compose?


上一篇:Docker的那些事兒—什么是docker compose?


安裝docker-compose

前提:已安裝Docker

對于Mac和Windows,Docker Toolbox已經(jīng)包含了Compose,因此不需要額外安裝。對于Linux環(huán)境,官網(wǎng)也提供了兩種方便的安裝方式:

1、二進制安裝(推薦)

2、PIP安裝

二進制安裝

1、curl下載最新版二進制文件

curl -L?https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname-s`-`uname -m` -o /usr/local/bin/docker-compose

Compose項目目前是在GitHub上進行維護的,目前最新穩(wěn)定版本是1.19.0。

地址:https://github.com/docker/compose/releases

2、增加可執(zhí)行權(quán)限

chmod +x /usr/local/bin/docker-compose

3、(可選)添加bash自動補全命令

curl? -L https://raw.githubusercontent.com/docker/compose/1.19.0/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose

可以參考:https://docs.docker.com/compose/completion/

4、測試安裝是否成功

?????? docker-compose version

root@Ubuntu-001:~# docker-compose version

docker-compose version1.19.0, build 9e633ef

docker-py version: 2.7.0

CPython version: 2.7.13

OpenSSL version: OpenSSL1.0.1t? 3 May 2016


PIP安裝(已安裝pip)

pip install docker-compose

安裝完Compose,查詢docker-compose命令


root@Ubuntu-001:~# docker-compose--help

Define and run multi-container applications with?Docker

Usage:

? docker-compose [-f ...] [options][COMMAND] [ARGS...]

? docker-compose -h|--help

Options:

? -f, --file FILE???????????? Specify an alternate compose file(default: docker-compose.yml)

? -p, --project-name NAME???? Specify an alternate project name(default: directory name)

? --verbose?????????????????? Show more output

? --no-ansi?????????????????? Do not print ANSI control characters

? -v, --version?????????????? Print version and exit

? -H, --host HOST???????????? Daemon socket to connect to


? --tls?????????????????????? Use TLS; implied by--tlsverify

? --tlscacert CA_PATH???????? Trust certs signed only by this CA

? --tlscert CLIENT_CERT_PATH? Path to TLS certificate file

? --tlskey TLS_KEY_PATH?????? Path to TLS key file

? --tlsverify???????????????? Use TLS and verify the remote

? --skip-hostname-check?????? Don't check the daemon's hostname against the name specified

????????????????????????????? in the clientcertificate (for example if your docker host

????????????????????????????? is an IP address)

? --project-directory PATH??? Specify an alternate working directory

????????????????????????????? (default: thepath of the Compose file)


Commands:

? build?????????????Build or rebuild services

? bundle???????????? Generate a Docker bundle from the Compose file

? config???????????? Validate and view the Compose file

? create???????????? Create services

? down?????????????? Stop and remove containers, networks, images, and volumes

? events???????????? Receive real time events from containers

? exec?????????????? Execute a command in a running container

? help?????????????? Get help on a command

? images???????????? List images

? kill?????????????? Kill containers

? logs?????????????? View output from containers

? pause????????????? Pause services

? port?????????????? Print the public port for a port binding

? ps???????????????? List containers

? pull?????????????? Pull service images

? push?????????????? Push service images

? restart??????????? Restart services

? rm???????????????? Remove stopped containers

? run??????????????? Run a one-off command

? scale????????????? Set number of containers for a service

? start????????????? Start services

? stop?????????????? Stop services

? top??????????????? Display the running processes

? unpause??????????? Unpause services

? up???????????????? Create and start containers

? version??????????? Show the Docker-Compose version information


卸載docker-compose

1、如果你使用二進制安裝的

rm /usr/local/bin/docker-compose

2、如果你通過PIP安裝的

pip uninstall docker-compose



下一篇:Docker的那些事兒—一個例子教你docker compose是如何使用的(一)?



最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容