docker_practice/compose/commands.md

291 lines
8.2 KiB
Go
Raw Permalink Normal View History

# Compose
2015-05-08 20:10:01 +08:00
##
2016-12-20 15:35:52 +08:00
Compose
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
`docker-compose [COMMAND] --help` `docker-compose help [COMMAND]` 使
2015-05-08 20:10:01 +08:00
2017-11-26 09:54:04 +08:00
`docker-compose` 使
2016-12-20 15:35:52 +08:00
2017-11-23 15:48:52 +08:00
```bash
2016-12-20 15:35:52 +08:00
docker-compose [-f=<arg>...] [options] [COMMAND] [ARGS...]
2015-05-08 20:10:01 +08:00
```
##
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
* `-f, --file FILE` 使 Compose `docker-compose.yml`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `-p, --project-name NAME` 使
2017-11-23 15:48:52 +08:00
2015-05-08 20:10:01 +08:00
* `--verbose`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `-v, --version` 退
2015-05-08 20:10:01 +08:00
## 使
2015-05-08 20:10:01 +08:00
### `build`
2017-11-23 22:08:41 +08:00
2016-12-20 15:35:52 +08:00
`docker-compose build [options] [SERVICE...]`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
web db web_db
2015-05-08 20:10:01 +08:00
`docker-compose build`
2016-12-20 15:35:52 +08:00
* `--force-rm`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--no-cache` 使 cache
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--pull` pull
### `config`
2017-11-23 22:08:41 +08:00
Compose
### `down`
2017-11-23 22:08:41 +08:00
`up`
### `exec`
2017-11-23 22:08:41 +08:00
### `help`
2015-05-08 20:10:01 +08:00
### `images`
2017-11-23 22:08:41 +08:00
Compose
### `kill`
2016-12-20 15:35:52 +08:00
`docker-compose kill [options] [SERVICE...]`
`SIGKILL`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
`-s` `SIGINT`
2017-11-23 15:48:52 +08:00
```bash
2015-05-08 20:10:01 +08:00
$ docker-compose kill -s SIGINT
```
### `logs`
2016-12-20 15:35:52 +08:00
`docker-compose logs [options] [SERVICE...]`
docker-compose 使 `--no-color`
### `pause`
2016-12-20 15:35:52 +08:00
`docker-compose pause [SERVICE...]`
### `port`
2016-12-20 15:35:52 +08:00
`docker-compose port [options] SERVICE PRIVATE_PORT`
* `--protocol=proto` tcp udp
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--index=index` 1
### `ps`
2016-12-20 15:35:52 +08:00
`docker-compose ps [options] [SERVICE...]`
2015-05-08 20:10:01 +08:00
2017-11-23 15:48:52 +08:00
* `-q` ID
2015-05-08 20:10:01 +08:00
### `pull`
2016-12-20 15:35:52 +08:00
`docker-compose pull [options] [SERVICE...]`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
* `--ignore-pull-failures`
2015-05-08 20:10:01 +08:00
### `push`
2017-11-23 22:08:41 +08:00
2017-11-23 23:38:05 +08:00
Docker
2017-11-23 22:08:41 +08:00
### `restart`
2016-12-20 15:35:52 +08:00
`docker-compose restart [options] [SERVICE...]`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
* `-t, --timeout TIMEOUT` 10
2015-05-08 20:10:01 +08:00
### `rm`
2016-12-20 15:35:52 +08:00
`docker-compose rm [options] [SERVICE...]`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
`docker-compose stop`
* `-f, --force` 使
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `-v`
### `run`
2016-12-20 15:35:52 +08:00
`docker-compose run [options] [-p PORT...] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]`
2015-05-08 20:10:01 +08:00
2017-11-23 15:48:52 +08:00
```bash
2015-05-08 20:10:01 +08:00
$ docker-compose run ubuntu ping docker.com
```
2016-12-20 15:35:52 +08:00
ubuntu `ping docker.com`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
*
2017-11-23 15:48:52 +08:00
2015-05-08 20:10:01 +08:00
*
使 `--no-deps`
2017-11-23 15:48:52 +08:00
```bash
2015-05-08 20:10:01 +08:00
$ docker-compose run --no-deps web python manage.py shell
```
web
2016-12-20 15:35:52 +08:00
* `-d`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--name NAME`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--entrypoint CMD`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `-e KEY=VAL` 使
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `-u, --user=""` uid
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--no-deps`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--rm` `d`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `-p, --publish=[]`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--service-ports`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `-T` tty tty
2015-05-08 20:10:01 +08:00
### `scale`
2016-12-20 15:35:52 +08:00
`docker-compose scale [options] [SERVICE=NUM...]`
2015-05-08 20:10:01 +08:00
`service=num`
2017-11-23 15:48:52 +08:00
```bash
2016-12-20 15:35:52 +08:00
$ docker-compose scale web=3 db=2
2015-05-08 20:10:01 +08:00
```
2016-12-20 15:35:52 +08:00
3 web 2 db
* `-t, --timeout TIMEOUT` 10
### `start`
2016-12-20 15:35:52 +08:00
`docker-compose start [SERVICE...]`
2015-05-08 20:10:01 +08:00
### `stop`
2016-12-20 15:35:52 +08:00
`docker-compose stop [options] [SERVICE...]`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
`docker-compose start`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
* `-t, --timeout TIMEOUT` 10
2015-05-08 20:10:01 +08:00
### `top`
2017-11-23 22:08:41 +08:00
### `unpause`
2016-12-20 15:35:52 +08:00
`docker-compose unpause [SERVICE...]`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
### `up`
2016-12-20 15:35:52 +08:00
`docker-compose up [options] [SERVICE...]`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
`docker-compose up` 便
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
`Ctrl-C`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
使 `docker-compose up -d`使
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
`docker-compose up` 使 `volumes-from` `docker-compose.yml` 使 `docker-compose up --no-recreate`使 `docker-compose up --no-deps -d <SERVICE_NAME>`
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
2015-05-08 20:10:01 +08:00
2016-12-20 15:35:52 +08:00
* `-d`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--no-color` 使
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--no-deps`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--force-recreate` `--no-recreate` 使
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--no-recreate` `--force-recreate` 使
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `--no-build`
2017-11-23 15:48:52 +08:00
2016-12-20 15:35:52 +08:00
* `-t, --timeout TIMEOUT` 10
2015-05-08 20:10:01 +08:00
### `version`
2016-12-20 15:35:52 +08:00
`docker-compose version`
2015-05-08 20:10:01 +08:00
2017-11-23 15:48:52 +08:00
##
* [](https://docs.docker.com/compose/reference/overview/)