Docker Basic
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 images | List images |
docker rmi image_name | Delete image |
docker pull image | Download the image |
container
docker run image_name | Download image and run |
docker ps | show current running container detail |
docker ps -a | show current and exited container detail |
docker start container_name/container_id | Run stoped container |
docker stop container_name/container_id | Stop running container |
docker exe -it container command_name | execute command on running container |
docker -d run image_name | run container in detach mode |
docker attach container_name | make the container run in foreground |
docker run -name custom_ame image_name | Download image and run with custom_name |
docker container -f prune | Delete all stoped container |
docker logs -f container_id/container_name | To see the container logs |
Miscellaneous
Command | Description | Comment |
docker images -aq | Show only id | -a : all |
-q : quite (show only ID) | ||
docker rmi docker images -aq | Delete all images | |
docker system prune | Delete all image+stoped container | |
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
ย