How to automatically delete a Docker container after running it
powercms.in·2d
🐳Docker
Preview
Report Post

Articles

Posted bynitheesh,31st Aug 2016

Normally, a Docker container persists after it has exited. This allows you to run the container again, inspect its filesystem, and so on. However, sometimes you want to run a container and delete it immediately after it exits. Docker provides the –rm command line option for this purpose:


docker run --rm my-docker

This will create a container from the "my-docker" image and delete the container immediately after it exits. This helps to prevent having to clean up containers after you’re done experimenting.

Note: The –rm flag doesn’t work in conjunction with the -d (–detach) flag. When –rm flag is set, Docker also removes the volumes associated with the container when the container is removed. This is similar to running doc…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help