Sunday, February 4, 2018

Docker commands

#Build: To build, create a Dockerfile in a directory and inside the directory run the following command: (Change NAME with your image name)
docker build -t NAME .

#List Docker Images:
docker images

#Remove Docker Image
docker image rm -f ID

#Run: To run the container image called NAME with following options:
1. Map the host port 80 with container port 80
2. Limit memory to 1000MB
3. Limit CPU = 1
4. Assign name = NAME
--use the following command:
docker run --rm -it -p 80:80 -m 1000m --cpus=1 --name=NAME NAME

#List Docker processes
docker ps

#See a live stream of container(s) resource usage statistics (like top)
docker container stats

#Display the running processes of a container (one shot)
docker container top NAME

#Check iptables for port mapping:
sudo iptables -t nat -L -n

#Commit Container or take a snapshot while running:
docker commit NAME NAME:run


No comments:

Post a Comment