Ankit Shah
2 min readFeb 3, 2023

Docker Documentation

Docker container — portable and can be shared containers with anyone.

It is not a virtual machine — carved up into different places.

Container — has everything that one needs to run the code in the container.

Networking, process code and each container has its own world and a web server which talks to the other container Docker is one which moniters it.

Docker — client program and as well as a server program which manages a running linux system. A program which builds its own code. A service which distributes docker.

Docker contains the docker code, node js and all installation of the image which one needs. This image designed on top of that machine and we can run as many containers as much processor and ram memory availabile. Build environment and we can run the environment anywhere.

Dockerhub and quay.io and any other machine can run the image.

Use the following command to check the running docker instances

Docker ps

  1. Use the following command to check the running and past running docker instances

Docker ps –a => -a option is able to show the hidden instances.

  1. Run the docker instance

docker run –it –-name <somename> -d Ubuntu

  1. Get the container id of the attached docker run.

docker ps –l

  1. Exit the container

exit

  1. Start the docker container

Docker start <container id>

  1. Attach the container id

docker attach <container id>

docker ps –l -> Gives the last exited docker container information

Commit the container containing the information

docker commit <container id>

docker tag <image id — one which gets printed post docker commit command> <image name>

Use command docker images to check which images are saved.

docker list containers which are exited

docker ps -aq -f status=exited

Remove Stopped Containers

docker ps -aq — no-trunc | xargs docker rm

This will not remove running containers

Remove dangling/untagged images

docker images -q — filter dangling=true | xargs docker rmi

Remove containers created after a specific container

docker ps — since a1bz3768ez7g -q | xargs docker rm

Remove containers created before a specific container

docker ps — before a1bz3768ez7g -q | xargs docker rm

Connect to same docker container

Docker exec -it <container id> bash

docker exec -ti — env COLUMNS=`tput cols` — env LINES=`tput lines` container id bash

In order to copy a file from a container to the host, you can use the command

docker cp <containerId>:/file/path/within/container /host/path/target

docker rmi -> docker remove images

https://linuxconfig.org/how-to-move-docker-s-default-var-lib-docker-to-another-directory-on-ubuntu-debian-linux

Ankit Shah
Ankit Shah

Written by Ankit Shah

LLM Architecture Associate Director at Accenture.

No responses yet