简体   繁体   English

如何在不运行所有其他服务的情况下部署开发容器?

[英]How do I deploy a dev container without running every other service?

Below is a docker-compose.yml from Visual Studio Code "Go & PostgreSQL" development container preset (original avaiable here ):下面是来自 Visual Studio Code“Go & PostgreSQL”开发容器预设的docker-compose.yml此处提供原始版本):

version: '3.8'

volumes:
  postgres-data:
    null

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        VARIANT: 1.18-bullseye
        NODE_VERSION: "lts/*"
    env_file:
      - .env

    volumes:
      - ..:/workspace:cached

    command: sleep infinity

    network_mode: service:db

  db:
    image: postgres:latest
    restart: unless-stopped
    volumes:
      - postgres-data:/var/lib/postgresql/data
    env_file:
      - .env

How do I set, for instance, the db service to not start along with the development container itself?例如,如何设置db服务不与开发容器本身一起启动? Adding profile: ["foo"] or restart: no to the db service resulted in the following error:添加profile: ["foo"]restart: nodb服务导致以下错误:

Start: Run: docker-compose -f /home/usr/go/src/github.com/foo/go-postgres/.devcontainer/docker-compose.yml --profile * config
Stop (109 ms): Run: docker-compose -f /home/usr/go/src/github.com/foo/go-postgres/.devcontainer/docker-compose.yml --profile * config
Error: Command failed: docker-compose -f /home/usr/go/src/github.com/foo/go-postgres/.devcontainer/docker-compose.yml --profile * config
    at Ru (/home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js:210:813)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async pR (/home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js:182:643)
    at async dR (/home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js:179:2075)
    at async IR (/home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js:224:2195)
    at async Xw (/home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js:224:3221)
    at async kR (/home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js:224:13925)
    at async TR (/home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js:224:13650)
Stop (391 ms): Run in Host: /home/usr/.vscode-server/bin/dfd34e8260c270da74b5c2d86d61aee4b6d56977/node /home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js up --container-data-folder .vscode-server/data/Machine --container-system-data-folder /var/vscode-server --workspace-folder /home/usr/go/src/github.com/foo/go-postgres --workspace-mount-consistency cached --id-label vsch.local.folder=\\wsl.localhost\Ubuntu-20.04\home\usr\go\src\github.com\foo\go-postgres --id-label vsch.quality=stable --log-level debug --config /home/usr/go/src/github.com/foo/go-postgres/.devcontainer/devcontainer.json --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root t
Exit code 1
Command failed: /home/usr/.vscode-server/bin/dfd34e8260c270da74b5c2d86d61aee4b6d56977/node /home/usr/.vscode-remote-containers/dist/dev-containers-cli-0.231.6/dist/spec-node/devContainersSpecCLI.js up --container-data-folder .vscode-server/data/Machine --container-system-data-folder /var/vscode-server --workspace-folder /home/usr/go/src/github.com/foo/go-postgres --workspace-mount-consistency cached --id-label vsch.local.folder=\\wsl.localhost\Ubuntu-20.04\home\usr\go\src\github.com\foo\go-postgres --id-label vsch.quality=stable --log-level debug --config /home/usr/go/src/github.com/foo/go-postgres/.devcontainer/devcontainer.json --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true

The command above was executed by the Remote-Containers Visual Studio Code extension.上面的命令是由 Remote-Containers Visual Studio Code 扩展执行的。

You should be able to use the runServices property in devcontainer.json .您应该能够使用devcontainer.json中的runServices属性。 According to the documentation , that will allow you to specify which services start up when opening the devcontainer.根据文档,这将允许您指定在打开 devcontainer 时启动哪些服务。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将在boot2docker中运行的Docker容器连接到在另一台主机上运行的网络服务? - How do I connect a Docker container running in boot2docker to a network service running on another host? 每个暴露的端口都重定向到 8080,我如何将 map 容器端口重定向到 8080 以外的任何其他端口? - Every exposed port is redirecting to 8080, how do I map container port to any other rather than 8080? 在Windows的Docker中,如何从我在机器上拥有的容器访问在我的开发机器上运行的webapi? - In Docker for windows, how do i access a webapi running on my dev machine from the container i aslo have on my machine? 如何代理在docker容器中运行的dotnet核心应用程序的每个请求 - How do I proxy every request from a dotnet core app running in a docker container 如何将Eureka服务ip传递给在docker容器中运行的java应用程序? - How do I pass Eureka service ip to my java application running in a docker container? 如何在 Jenkinsfile 中停止正在运行的容器? - How do I stop a running container in Jenkinsfile? 如何在不需要任何PHP脚本的情况下运行PHP-CLI容器? - How do I keep a PHP-CLI container running without the need of any PHP script? 如何按名称查找正在运行的容器? - How do I find a running container by name? 我如何访问在Docker容器(由Rancher管理)中运行的MySQL,而不在主机上发布端口? - How do I access MySQL running in a docker container (managed by Rancher) without publishing the port on the host? 如何在加载 docker 容器而不运行 docker-compose 后运行它? - How do I run my docker container after loading it without running docker-compose up?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM