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). |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
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.jsonfile has convenientpostCreateCommandandpostStartCommandoptions, but apparently nothing for shutdown. There is ashutdownActiondefined, 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?
All reactions