Open sarj21 opened 1 month ago
I recommend building the image with a separate configuration (this can be just a Dockerfile
or a devcontainer.json
) and then reference the resulting image in the docker-compose.yml
without referencing a Dockerfile
. This avoids relying on Docker's cache hits across machines and potentially architectures.
We have the following
devcontainers.json
file at.devcontainers/flask/devcontainers.json
:Running
devcontainer up --workspace-folder . --config .devcontainer/flask/devcontainer.json
works fine, it builds the image and stands up the docker compose service.I want to utilize prebuilding with our docker compose stack so I take the resulting built images and push them to our repository. If anyone pulls those images and runs
devcontainer up --workspace-folder . --config .devcontainer/flask/devcontainer.json
it rebuilds the entire image from scratchIf in the devcontainers.json I use the
image
field then it doesn't rebuild but there's no good way to use something like VS Code's> Reopen in Container
since it doesn't know it part of the docker compose stack.Does devcontainers support using prebuilt images with docker compose files? Is there somethings special I need to do to get it to recognize the image is fully built or to point directly at the cache?
To me it seems like it seems to be running
docker compose build
instead ofdocker compose up
when runningdevcontainers up
. If I rundocker compose up
myself and then attach VS Code it seems to work as intended.