You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 convenient postCreateCommand and postStartCommand options, but apparently nothing for shutdown. There is a shutdownAction defined, but seemingly unrelated. I'm essentially looking for a way to set up a shutdownCommand.
I attempted to do this by trapping EXIT in the postStartCommand, e.g.:
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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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