Skip to content

Commit 0762798

Browse files
author
bamurtaugh
committed
Update advanced info
1 parent c03bbee commit 0762798

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

docs/remote/devcontainer-cli.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ On the other hand, if you only intend to use the pre-built image from one reposi
185185
}
186186
}
187187

188+
## Avoiding problems with images built using Docker
189+
190+
Given Dockerfiles and Docker Compose files can be used without VS Code or the `devcontainer` CLI, you may want to let users know that they should not try to build the image directly. You may learn more in the [advanced dev container documentation](../../remote/advancedcontainers/reduce-docker-warnings.md#avoiding-problems-with-images-built-using-docker).
191+
188192
## Feedback
189193

190194
The dev container CLI and specification are under active development and we welcome your feedback, which you can provide in [this issue](https://github.com/devcontainers/cli/issues/7), or through new issues and pull requests in the [devcontainers/cli](https://github.com/devcontainers/cli) repository.

remote/advancedcontainers/reduce-docker-warnings.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,25 @@ RUN apt-get -y install --no-install-recommends apt-utils dialog 2>&1
5454
```
5555

5656
If the command fails, you will still be able to see the errors but they won't be in red.
57+
58+
## Avoiding problems with images built using Docker
59+
Given Dockerfiles and Docker Compose files can be used without VS Code or the `devcontainer` CLI, you may want to let users know that they should not try to build the image directly if it will not work as expected. To solve this problem, you can add a build argument that needs to be specified for things to work.
60+
61+
For example, you could add the following to your Dockerfile:
62+
```bash
63+
ARG vscode
64+
RUN if [[ -z "$devcontainercli" ]] ; then printf "\nERROR: This Dockerfile needs to be built with VS Code !" && exit 1; else printf "VS Code is detected: $devcontainercli"; fi
65+
```
66+
67+
And the following in your `devcontainer.json`:
68+
```json
69+
"build": {
70+
"dockerfile": "Dockerfile",
71+
"args": {
72+
// set devcontainer-cli arg for Dockerfile
73+
"devcontainercli": "true"
74+
},
75+
}
76+
```
77+
78+
In the Docker Compose case, you can add this argument to a separate [override file to extend your configuration](https://github.com/microsoft/vscode-docs/blob/a55ae5b286196b495e2b3ea9f0b3e211beb7c925/docs/remote/create-dev-container.md#extend-your-docker-compose-file-for-development) that is located in a different place in your source tree than the primary Docker Compose file.

0 commit comments

Comments
 (0)