Skip to content

Instantly share code, notes, and snippets.

@soardex
Created January 18, 2016 10:19
Show Gist options
  • Save soardex/d9d3967832730bf4f5dd to your computer and use it in GitHub Desktop.
Save soardex/d9d3967832730bf4f5dd to your computer and use it in GitHub Desktop.
My Most Used Docker Commands
# build docker config
docker build -t [name:tag] .
# inspecting containers
docker inspect [container-id]
# create an image from a container
docker commit -a [author] -m [message] [container-id] [name:tag]
# compare docker container with image
docker diff [container-id]
# run and delete the container after it exits
docker run --rm -ti [image] /bin/bash
# delete all the containers on Docker host
docker rm $(docker ps -aq)
# delete all images on Docker host
docker rmi `docker images -q`
# delete untagged images
docker rmi `docker images -q -f "dangling=true"`
# attaching to existing docker container
docker exec -ti [container-id] /bin/bash
# another way of attaching using `nsenter` or Namespace Enter
PID=$(docker inspect --format \ [container-id])
nsenter --target $PID --mount --uts --ipc --net --pid
# getting logs from container namespace
docker logs [container-id]
# getting returned status
echo $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment