-
From @stephenandary Hello :). I am wondering about a use case where I can build and push a devcontainer including post create commands so that a developer just needs to reference the built image. Some post create commands take very long and it would be nice to just build when updating for people. I tried to do this but when I referenced the image, it ran all of the build again. Wondering if doing this is possible (maybe I did something wrong). Github Action Workflow Used: https://github.com/stephenandary/Dev_Containers/blob/main/.github/workflows/Rust-Dev_image_release.yml#L1-L30 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 14 replies
-
postCreateCommand happens after the container has been created. As a result, its contents cannot be added to an image. Its intended to perform steps that requires the source code to be present to execute. A classic example is However, if this is your postCreateCommand, then it looks like all of those contents can be executed w/o the source code, so there's two options. Add to a DockerfileYou can add many of these commands to your Dockerfile. You can add it as follows:
Or to run as a user other than
A gotcha is that sometimes things require a
Use a local featureHowever, if you want to run commands that depend on a specific Dev Container Feature, you can use a local feature. All Dev Container Features capabilities are available in local features, you just don't have to publish them if you don't want to. Here's how to convert that script into a local feature:
That help? |
Beta Was this translation helpful? Give feedback.
-
@Chuxel, within
and variations on:
|
Beta Was this translation helpful? Give feedback.
postCreateCommand happens after the container has been created. As a result, its contents cannot be added to an image. Its intended to perform steps that requires the source code to be present to execute. A classic example is
yarn install
.However, if this is your postCreateCommand, then it looks like all of those contents can be executed w/o the source code, so there's two options.
Add to a Dockerfile
You can add many of these commands to your Dockerfile. You can add it as follows:
Or to run as a user other than
root
: