Replies: 1 comment
-
Thanks for opening this discussion! I believe the changes that could come with devcontainers/cli#386 would help in this scenario (the CLI would need to handle this, since Docker wouldn't perform / manage shutdown). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello. As the title says, my goal is run a command when the dev container shuts down. I want to perform clean-up work, such as deleting the /node_modules/ directory in the project folder.
The
devcontainer.json
file has convenientpostCreateCommand
andpostStartCommand
options, but apparently nothing for shutdown. There is ashutdownAction
defined, but seemingly unrelated. I'm essentially looking for a way to set up ashutdownCommand
.I attempted to do this by trapping EXIT in the postStartCommand, e.g.:
"postStartCommand": "trap \"rm -rf ${containerWorkspaceFolder}/node_modules\" EXIT"
Unfortunately, this didn't work as intended. Instead of running on shutdown, it runs at the end of the startup sequence, as it catches the startup sequence exiting.
What is the proper way to handle this?
Beta Was this translation helpful? Give feedback.
All reactions