Docker Commands - Explained

ยท

3 min read

Docker Commands - Explained

Container Lifecyle Commands

module - 7 (8).png


  • Create an container without starting it
    docker create [image]
    
  • Rename a container
    docker rename [container_name] [new_container_nme]
    
  • Create and start a container
    docker run [image]
    
  • Remove the container when it stops
    docker run --rm [image]
    
  • Start an container and keep it running
    docker run -td [image]
    
  • Create and Start the container and to allow us enter commands
    docker run -it [image]
    
  • Create and start the container and run a command in it and after execution, remove the container
    docker run -it-rm [image]
    
  • Delete a container
    docker rm [container]
    
  • Update a container configuration
    docker update [container]
    

Image Lifecycle Commands

module - 7 (9).png

  • Build an image using Dockerfile
    docker build [path]
    
  • Build an Image with a Tag
    docker build -t [path]
    
  • Pull an image from registry (DockerHub)
    docker pull [image]
    
  • Push an image from registry
    docker push [image]
    
  • Create an image using tarball
    docker import [path(or)STDIN_FILE]
    
  • Remove an Image
    docker rmi [image]
    
  • Load an image from tar
    docker load [tar_file]
    
  • Save an Image to a tar
    docker save [image] > [tar_file]
    

Networking Commands

module - 7 (10).png

  • List Networks
    docker network ls
    
  • Remove one (or) more networks
    docker network rm [networks]
    
  • Show information about one or more contaienrs
    docker network coonect [network] [container]
    
  • Connect a container to a network
    docker network connect [network] [container]
    
  • Disconnect a container from a network
    docker network disconnect [network] [container]
    

Start and Stop Commands

module - 7 (11).png

  • Start a container
    docker start [container]
    
  • Stop a container
    docker stop [container]
    
  • Restart a container
    docker restart [container]
    
  • Pause a Conatiner
    docker pause [conatiner]
    
  • Unpause a container
    docker unpause [container]
    
  • Block a container untill other container stops
    docker wait [container]
    
  • Kill a container by sending a SIGKILL to a running container
    docker kill [container]
    
  • Attach Local standard input,output and error streams to a running container
    docker attach [container]
    

Information Commands

module - 7 (12).png

  • List Running Containers
    docker ps
    
  • List all running and stopped containers
    docker ps -a
    
  • Logs of a container
    docker logs [container]
    
  • List low level information on an object
    docker inspect [obj_name/id]
    
  • List Realtime events from a container
    docker events [container]
    
  • Show Mapping port of a container
    docker port [container]
    
  • Show running processes in a container
    docker top [container]
    
  • Show live resource usage statistics of containers
    docker stats [container]
    
  • Show Changes to files on filesystem
    docker diff [container]
    
  • Show all locally stored images
    docker images ls
    
  • Show history of an image
    docker history [image]
    

Visit Docker Series for all the docker posts and make sure to show your support ๐Ÿ˜‰

Did you find this article valuable?

Support Cloud Maestro by becoming a sponsor. Any amount is appreciated!

ย