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

CommandDescriptionComment
docker images -aqShow only id-a : all
-q : quite (show only ID)
docker rmi docker images -aqDelete all images
docker system pruneDelete all image+stoped container
docker ps -aqshow only id
docker ps -aqdocker rm docker ps -aq
Delete all containerdocker search image_image
docker search image_imagesearch for image in docker repo
docker inspect container_id/container_nameTo view container in detail
docker run -it image commandstart 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
ย