Useful Docker commands

 Docker Container Commands

Most useful commands for docker . These  commands  mostly and frequently use  for docker operation.  


We can  create  container  from  the existing  images .

docker create [IMAGE]

Find  list  of  existing  images .

docker image  ls


We can  pull  docker  images  from docker hub.  We need to log in first  docker hub.

docker pull  [IMAGE]


To get  full details    from  the existing  images .

docker inspect [IMAGE]

 To remove  unused  images.

docker purne  [IMAGE]

To build  existing  image

docker build [IMAGE]



Rename an existing container:



Run a command in a new container:

docker run [IMAGE] [COMMAND]

docker run --rm [IMAGE] – removes a container after it exits.

docker run -td [IMAGE] – starts a container and keeps it running.

docker run -it [IMAGE] – starts a container, allocates a pseudo-TTY connected to the container’s stdin, and creates an interactive bash shell in the container.

docker run -it-rm [IMAGE] – creates, starts, and runs a command inside the container. Once it executes the command, the container is removed.

Delete a container (if it is not running):

docker rm [CONTAINER]

Update the configuration of one or more containers:

docker update [CONTAINER]

Starting and Stopping Containers


Start a container:

docker start [CONTAINER]

Stop a running container:

docker stop [CONTAINER]

Stop a running container and start it up again:

docker restart [CONTAINER]

Pause processes in a running container:

docker pause [CONTAINER]

Unpause processes in a running container:

docker unpause [CONTAINER]

Block a container until others stop (after which it prints their exit codes):

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]

Step  to pulling and running tomcat  outside container

docker pull tomcat



Allocate  the port 8888 to connect the docker engine


docker run -it --rm -p 8888:8080 tomcat:8.0


And Tomcat server is available on the port 8888.To connect the running sever. we need to run this command curl.


  $curl localhost:8888




Useful Docker commands Useful Docker commands Reviewed by Mukesh Jha on 9:18 AM Rating: 5

No comments:

Add your comment

All Right Reserved To Mukesh Jha.. Theme images by Jason Morrow. Powered by Blogger.