docker_practice/compose/install.md

127 lines
3.6 KiB
Go
Raw Normal View History

2016-12-20 15:35:52 +08:00
##
2015-05-08 20:10:01 +08:00
`Compose` LinuxmacOSWindows 10
2016-12-20 15:35:52 +08:00
`Compose` Python `pip` 使 Docker
2016-12-20 15:35:52 +08:00
使
2015-05-08 20:10:01 +08:00
`Docker for Mac` `Docker for Windows` `docker-compose` Docker 使
2017-11-23 15:48:52 +08:00
```bash
$ docker-compose --version
docker-compose version 1.17.1, build 6d101fb
```
Linux 使
###
Linux [ GitHub Release](https://github.com/docker/compose/releases) 处直接下载编译好的二进制文件即可。
2017-11-23 15:48:52 +08:00
Linux 64
2017-11-23 15:48:52 +08:00
```bash
$ sudo curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
2017-11-23 15:48:52 +08:00
```
2015-05-08 20:10:01 +08:00
### PIP
2017-11-23 15:48:52 +08:00
** `x86_64` Linux `ARM` ()使 `pip`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
Compose Python pip
2015-05-08 20:10:01 +08:00
2017-11-22 11:13:23 +08:00
```bash
2015-05-08 20:10:01 +08:00
$ sudo pip install -U docker-compose
```
2016-12-20 15:35:52 +08:00
2017-11-23 15:48:52 +08:00
2017-11-22 11:13:23 +08:00
```bash
2016-12-20 15:35:52 +08:00
Collecting docker-compose
2017-11-23 15:48:52 +08:00
Downloading docker-compose-1.17.1.tar.gz (149kB): 149kB downloaded
2016-12-20 15:35:52 +08:00
...
Successfully installed docker-compose cached-property requests texttable websocket-client docker-py dockerpty six enum34 backports.ssl-match-hostname ipaddress
```
2017-11-23 15:48:52 +08:00
### bash
2015-05-08 20:10:01 +08:00
2017-11-22 11:13:23 +08:00
```bash
2016-12-20 15:35:52 +08:00
$ curl -L https://raw.githubusercontent.com/docker/compose/1.8.0/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose
2015-05-08 20:10:01 +08:00
```
2016-12-20 15:35:52 +08:00
###
Compose Python
2017-11-22 11:13:23 +08:00
```bash
2016-12-20 15:35:52 +08:00
$ curl -L https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
```
`run.sh`
2017-11-22 11:13:23 +08:00
```bash
2016-12-20 15:35:52 +08:00
set -e
VERSION="1.8.0"
IMAGE="docker/compose:$VERSION"
# Setup options for connecting to docker host
if [ -z "$DOCKER_HOST" ]; then
DOCKER_HOST="/var/run/docker.sock"
fi
if [ -S "$DOCKER_HOST" ]; then
DOCKER_ADDR="-v $DOCKER_HOST:$DOCKER_HOST -e DOCKER_HOST"
else
DOCKER_ADDR="-e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH"
fi
# Setup volume mounts for compose config and context
if [ "$(pwd)" != '/' ]; then
VOLUMES="-v $(pwd):$(pwd)"
fi
if [ -n "$COMPOSE_FILE" ]; then
compose_dir=$(dirname $COMPOSE_FILE)
fi
# TODO: also check --file argument
if [ -n "$compose_dir" ]; then
VOLUMES="$VOLUMES -v $compose_dir:$compose_dir"
fi
if [ -n "$HOME" ]; then
VOLUMES="$VOLUMES -v $HOME:$HOME -v $HOME:/root" # mount $HOME in /root to share docker.config
fi
# Only allocate tty if we detect one
if [ -t 1 ]; then
DOCKER_RUN_OPTIONS="-t"
fi
if [ -t 0 ]; then
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i"
fi
exec docker run --rm $DOCKER_RUN_OPTIONS $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w "$(pwd)" $IMAGE "$@"
```
`docker/compose`
###
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
2017-11-22 11:13:23 +08:00
```bash
2016-12-20 15:35:52 +08:00
$ sudo rm /usr/local/bin/docker-compose
```
2017-11-26 09:54:04 +08:00
`pip`
2015-05-08 20:10:01 +08:00
2017-11-22 11:13:23 +08:00
```bash
2016-12-20 15:35:52 +08:00
$ sudo pip uninstall docker-compose
2017-11-01 00:20:30 +08:00
```