Brief docker cheatsheet

Brief docker cheatsheet

Here are some notes I took while reading a Docker book some time back.

  • docker inspect <containerid> – Shows IPAddress among other things.
  • docker diff <containerid> – List of files changed in the container.
  • docker logs <containerid> – list of everything that happened in the container.
  • docker start <containerid> – Start an exited/stopped container. START IS FOR CONTAINERS.
  • docker rm <containerid> – Remove a container.
  • docker run -it --name mynewcontainer centos bash – Run bash in a container called ‘mynewcontainer’ with centos as the base.
  • docker commit mynewcontainer arun/mynewcontainer – Create an image out of a container (either running or stopped).
  • docker run arun/mynewcontainer echo hi – Run echo on a new container and exit.
  • docker build -t arun/mynewcontainer . – Read Dockerfile from PWD and build a new container with that tag.
  • docker push arun/mynewcontainer – Push to docker hub or some other registry.
  • docker pull arun/mynewcontainer – Pull from docker hub or some other registry.
  • docker run arun/mynewcontainer –name test -d /usr/bin/nginx – daemonize and run a pulled image. RUN IS FOR IMAGES.
  • docker run --rm -it --link myredis:redis redis /bin/bash – Woah. We ran another container and linked it to the existing ‘myredis’ container as ‘redis’ on the new one, i.e. /etc/hosts has an entry called ‘redis’ pointing to the old one.

Leave a Reply

%d bloggers like this: