Skip to content

postCreateCommand in image #5

Answered by Chuxel
Chuxel asked this question in Q&A
Nov 17, 2022 · 2 comments · 14 replies
Discussion options

You must be logged in to vote

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:

COPY ./scripts/postCreateCommand.sh /tmp
RUN bash /tmp/postCreateCommand.sh && rm -f /tmp/postCreateCommand.sh

Or to run as a user other than root:

COPY ./scripts/postCreateCommand.sh /tmp
USER vscode
RUN bas…

Replies: 2 comments 14 replies

Comment options

Chuxel
Nov 17, 2022
Maintainer Author

You must be logged in to vote
3 replies
@andar1an
Comment options

@Chuxel
Comment options

Chuxel Nov 18, 2022
Maintainer Author

@andar1an
Comment options

Answer selected by Chuxel
Comment options

You must be logged in to vote
11 replies
@andar1an
Comment options

@Chuxel
Comment options

Chuxel Dec 16, 2022
Maintainer Author

@andar1an
Comment options

@andar1an
Comment options

@andar1an
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants