Skip to content

Instantly share code, notes, and snippets.

@bschiffthaler
Last active April 16, 2019 08:43
Show Gist options
  • Save bschiffthaler/442f16a7318d0fb96981fedc54d4317f to your computer and use it in GitHub Desktop.
Save bschiffthaler/442f16a7318d0fb96981fedc54d4317f to your computer and use it in GitHub Desktop.

List all stopped containers

docker ps -a -f status=exited

Delete all stopped containers

docker rm $(docker ps -aq -f status=exited)

Stop all containers

docker stop $(docker ps -q)

List all images

docker images

Delete useless images

docker rmi $(docker images -q -f dangling=true)

Restart a stopped container with a new command

# Identify stopped container
docker ps -a
# Commit container
docker commit <container_id> <a_new_name>
# Start new session (make sure to re-use volume mounts, ports etc)
docker run ... <a_new_name> <a_new_command>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment