Zekeriya Akgül
Zekeriya Akgül

Reputation: 318

How can i run a script before destroy a docker container?

I need the run a shell script before destroy a docker container.But this script should not work when this container stopped.Only run when i destroy and rm this container.How can i do this?

Upvotes: 1

Views: 965

Answers (2)

Sha7x
Sha7x

Reputation: 485

Since it is not possible at the moment, you could use a workaround:

alias "docker-destroy"="<run-script> && docker rm"

For example:

alias "docker-destroy"="echo 'test' && docker rm"

Upvotes: 0

jaxxstorm
jaxxstorm

Reputation: 13261

It's not currently possible. Have a look at this issue for more information: https://github.com/docker/docker/issues/6982

Upvotes: 1

Related Questions