Docker is a popular virtualization tool that replicates a specific operating environment on top of a host OS. Each environment is called a container.
Its primary focus is to automate the deployment of applications inside software containers and the automation of operating system level virtualization on Linux. It’s more lightweight than standard Containers and boots up in seconds
- To Install Docker in Linux.
2. To start and check the status of docker.
3. To pull the docker Image.
4. To check what are all the images available.
5. To check the running process in docker.
6. To start and stop a specific container.
6. To list all running Docker containers.
7.To list all containers, both running and stopped, add –a
:
docker ps –a
8.To remove a specific container.
docker container rm <Container Id>
9. To remove all stopped containers use the docker container prune command.
docker container prune
10. If you want to get list of all non-running (stopped) containers that will be removed with docker container prune
, use the following command:
docker container ls -a --filter status=exited
11. To remove all images created more than 12 hours ago
docker container prune --filter "until=12h"
12. To define container name, use the ––name
option. If you do not define it for your newly created container, the daemon will generate a random string name by default.
docker run ––name=<name that you want to give> <Image_Name>
13. To remove docker Images.
docker rmi <Image_id>
docker image rm <Image_name>
14. To save docker image on a tar file
docker save -o <name.tar> {repo}:{tag}
docker save -o <name.tar> <Image_id>
docker save <img_name> | gzip > <file_name>.tar.gz
To unzip the tar.gz file to a tar file
guzip <file_name>.tar.gz