docker_practice/compose/commands.md

295 lines
8.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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