docker compose 命令与配置文件一起运行

标签 docker docker-compose

随着 docker 最近的更新,每当我运行 docker-compose up -d docker 引擎建议我使用以下行:

Docker Compose is now in the Docker CLI, try docker compose up


问题是我如何运行 docker compose带有配置文件选项的命令?
例如,在 docker-compose我可以将配置文件用作 docker-compose --profile dev up .docker compose有没有类似的也?
我查看了 CLI reference但没有找到任何东西。

最佳答案

docker composeprofile选项。尝试执行 docker compose --help在您的终端中,您将看到以下帮助部分,其中包含 profile 选项

╰>>> docker compose --help

Usage:  docker compose [OPTIONS] COMMAND

Docker Compose

Options:
      --ansi string                Control when to print ANSI control characters ("never"|"always"|"auto") (default "auto")
      --env-file string            Specify an alternate environment file.
  -f, --file stringArray           Compose configuration files
      --profile stringArray        Specify a profile to enable
      --project-directory string   Specify an alternate working directory
                                   (default: the path of the Compose file)
  -p, --project-name string        Project name

Commands:
  build       Build or rebuild services
  convert     Converts the compose file to platform's canonical format
  create      Creates containers for a service.
  down        Stop and remove containers, networks
  events      Receive real time events from containers.
  exec        Execute a command in a running container.
  images      List images used by the created containers
  kill        Force stop service containers.
  logs        View output from containers
  ls          List running compose projects
  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 containers
  rm          Removes stopped service containers
  run         Run a one-off command on a service.
  start       Start services
  stop        Stop services
  top         Display the running processes
  unpause     unpause services
  up          Create and start containers

Run 'docker compose COMMAND --help' for more information on a command.
如果你的 docker CLI 没有这个选项,你可能需要升级你的 docker CLI。
这是Docker CLI documentation--profile选项。

关于docker compose 命令与配置文件一起运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67652020/

相关文章:

Docker Compose 与多阶段构建

docker - Kubernetes 上的 Traefik 在传入连接上错误的客户端 IP

javascript - 使用 JavaScript 启动 Docker 机器

python - 无法在 Python 镜像上找到包 msodbcsql

Docker 容器中的 Elasticsearch - 简单重启后为 "failed to write in data directory"

docker - Traefik可以与docker-compose连接,但不能与Windows上的swarm服务连接

docker - 不允许 kubernetes mysql chown 操作

docker-compose:以特定用户身份创建命名卷

django - 无法在 docker 容器内运行 django 和 Gunicorn 的情况下在 EC2 上使用 nginx 提供静态文件

Docker-compose 不反射(reflect) requirements.txt 中的更改