[英]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: no
到db
服务导致以下错误:
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.