Key Docker Commands

  • Pull docker image from repository to local : docker pull <imageName> example docker pull busybox
  • Run a docker container : docker run <imageName> example docker run busybox
  • If there is nothing to execute docker will exit when the process terminates
  • To view all containers in local : docker ps -a
  • To view all running containers: docker ps
  • To stop a running container: docker stop <containerName>
  • To remove a container: docker rm <containerName>
  • To view all images pulled : docker images
  • To delete an image from local to free up space : docker rmi <imageName>
  • To run a container in background / detached mode use -d flag : docker run -d example docker run -d busybox:latest sleep 100
  • To run docker container in interactive mode with terminal access: docker run -i -t example docker run -i -t busybox:latest
  • To display low level information about a container or image: docker inspect or docker inspect
  • Deletes all containers that have a status of exited: docker container prune
  • To expose a port on the container and map that to port on host use -p option: docker run -p : imageName
  • To view logs of a container: docker logs containerName

Thank You !!!

2 thoughts on “Key Docker Commands

Leave a Reply