docker-compose

安装Docker-Compose:

官方文档

  1. 安装
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

要安装不同版本的 Compose,请将 1.29.2 替换为您要使用的 Compose 版本

  1. 授权
## 对二进制文件应用可执行权限
chmod +x /usr/local/bin/docker-compose
## 查看是否安装完成
docker-compose --version
  1. 配置软链(可选)
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Docker-Compose命令

[root@localhost128 home]# docker-compose --help
Define and run multi-container applications with Docker.

Usage:
  docker-compose [-f <arg>...] [--profile <name>...] [options] [--] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  ##  指定compose文件,默认为docker-compose.yml
  -f, --file FILE             Specify an alternate compose file (default: docker-compose.yml)
  ## 指定项目名称,默认为当前目录名称
  -p, --project-name NAME     Specify an alternate project name (default: directory name)
  --profile NAME              Specify a profile to enable
  -c, --context NAME          Specify a context name
  --verbose                   Show more output
  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  --ansi (never|always|auto)  Control when to print ANSI control characters
  --no-ansi                   Do not print ANSI control characters (DEPRECATED)
  -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 client certificate
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)
  --compatibility             If set, Compose will attempt to convert keys
                              in v3 files to their non-Swarm equivalent (DEPRECATED)
  --env-file PATH             Specify an alternate environment file

Commands:
  build              Build or rebuild services
  ## 验证并查看 Compose 文件
  config             Validate and view the Compose file
  create             Create services
  ## 停止并删除容器,可以指定单个服务 如:docker-compose down  <serviceName>
  down               Stop and remove resources
  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
  ## 启动服务,不指定名称就是启动所有, 指定就启动单个 如:docker-compose start  <serviceName>
  start              Start services
  ##停止服务,不指定名称就是停止所有, 指定就停止单个 如:docker-compose stop  <serviceName>
  stop               Stop services
  top                Display the running processes
  unpause            Unpause services
  ## 创建并启动容器,可以指定单个服务 如:docker-compose up  <serviceName>
  up                 Create and start containers
  version            Show version information and quit
posted @ 2023-02-12 20:27  菜阿  阅读(27)  评论(0编辑  收藏  举报