Docker Basic

ยท

2 min read

Docker utilizes the host operating system's kernel to provide lightweight containerization

Docker is used for containerization, which involves packaging an application and its dependencies into a container

Basic commands

Images

docker imagesList images
docker rmi image_nameDelete image
docker pull imageDownload the image

container

docker run image_nameDownload image and run
docker psshow current running container detail
docker ps -ashow current and exited container detail
docker start container_name/container_idRun stoped container
docker stop container_name/container_idStop running container
docker exe -it container command_nameexecute command on running container
docker -d run image_namerun container in detach mode
docker attach container_namemake the container run in foreground
docker run -name custom_ame image_nameDownload image and run with custom_name
docker container -f pruneDelete all stoped container
docker logs -f container_id/container_nameTo see the container logs

Miscellaneous

docker images -aqShow only id-a : all

-q : quite (show only ID) | | docker rmi docker images -aq | Delete all images | | | docker ps -aq | show only id | | | docker ps -aq | docker rm docker ps -aq | | | Delete all container | docker search image_image | | | docker search image_image | search for image in docker repo | | | docker inspect container_id/container_name | To view container in detail | | | docker run -it image command | start the container and execute the command | |

Port Expose

๐Ÿ‘‰๐Ÿป Host_port : Container_port

#docker run -p host_port:container_port nginx
docker run -p 80:80 nginx

Expose Volume

๐Ÿ‘‰๐Ÿป Host_volume : Container_volume

#docker run -p host_volume:container_volume nginx
docker run -v /ak/nginx:/usr/share/nginx/html nginx
ย