如何安装docker-compose?

安装docker-compose

前提:已安装Docker

对于Mac和Windows,Docker Toolbox已经包含了Compose,因此不需要额外安装。对于Linux环境,官网也提供了两种方便的安装方式:

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上进行维护的,目前最新稳定版本是1.19.0。

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

2、增加可执行权限

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

Defineand 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 hostnameagainst the name specified

in the client certificate (for example if your docker host

is an IP address)

--project-directory PATH Specify an alternate working directory

(default: the path 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

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180306G04G3P00?refer=cp_1026
  • 腾讯「云+社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 yunjia_community@tencent.com 删除。

扫码关注云+社区

领取腾讯云代金券