Update advanced info
This commit is contained in:
Родитель
c03bbee9c6
Коммит
0762798ceb
|
@ -185,6 +185,10 @@ On the other hand, if you only intend to use the pre-built image from one reposi
|
|||
}
|
||||
}
|
||||
|
||||
## Avoiding problems with images built using Docker
|
||||
|
||||
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).
|
||||
|
||||
## Feedback
|
||||
|
||||
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.
|
||||
|
|
|
@ -54,3 +54,25 @@ RUN apt-get -y install --no-install-recommends apt-utils dialog 2>&1
|
|||
```
|
||||
|
||||
If the command fails, you will still be able to see the errors but they won't be in red.
|
||||
|
||||
## Avoiding problems with images built using Docker
|
||||
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.
|
||||
|
||||
For example, you could add the following to your Dockerfile:
|
||||
```bash
|
||||
ARG vscode
|
||||
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
|
||||
```
|
||||
|
||||
And the following in your `devcontainer.json`:
|
||||
```json
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
"args": {
|
||||
// set devcontainer-cli arg for Dockerfile
|
||||
"devcontainercli": "true"
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
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.
|
Загрузка…
Ссылка в новой задаче