Sunday 25 December 2016

Docker commands cheetsheet

Most frequently used commands in docker

To view running containers
sudo docker ps   
To view the stopped and running containers
sudo docker ps -a 
To view all the docker images
sudo docker images 
To start the docker container
sudo docker start [container ID]  
To stop the container
sudo docker stop [container ID] 
To run tomcat image 
sudo docker run -d -p 8081:8080 tomcat:8.0   
[-d for detached mode, -p to sepcify the ports, -P to automatically assign the port]

To go inside the running container 
sudo docker exec -i -t [container ID] /bin/bash  
[-i to connect to the STDIN of the container, -t for pseudo terminal]

To view the container details
sudo docker inspect [container ID] 
To copy a file from host to the container
sudo docker cp file-web.war [container ID]:/usr/local/webapps  
To build an image from the dockerfile
sudo docker build -t imageName  
To commit a docker image
sudo docker commit [containerID]  [imageName]:[tag]  
To kill a docker container
sudo docker kill [containerID] 

No comments:

Post a Comment