Docker Commands for Beginners

Gopi M
3 min readJul 12, 2021

--

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

  1. To Install Docker in Linux.
fig-1

2. To start and check the status of docker.

fig-2

3. To pull the docker Image.

fig-3

4. To check what are all the images available.

fig-4

5. To check the running process in docker.

fig-5

6. To start and stop a specific container.

fig-6
fig-7

6. To list all running Docker containers.

fig-8

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

--

--

Gopi M
Gopi M

Written by Gopi M

Security Researcher, Web Application and Network Pentester, CTF Player, Bug Bounty Hunter, Interested in Learning Technical stuffs.

No responses yet