Docker Basics
Docker Container Docker Basics To know currently Running docker version docker --version To get detailed information about docker installation docker info Working with Containers to run a docker container # docker run [options] image-name [command] [args] # ex. docker run -d nginx to list running containers docker ps to list all the containers running or stopped docker ps -a to stop a running stop # docker stop [container_id/name] docker stop nginx to start a stopped container # docker start [container_id/name] docker start nginx to restart a container # docker restart [container_id/name] docker restart nginx to remove a stopped container # docker rm [container_id/name] docker rm nginx to check logs of a container # docker logs [container_id/name] docker logs nginx Docker images to list all the docker images docker images to download an image from docker hub # docker pull [image_name] docker pull nginx to build an image from a docker file # docker build -t [IMAGE_NAME:TAG] docker build -t to remove an docker image # docker rmi [IMAGE_NAME:TAG docker rmi nignx Docker volume to create a docker volumes # docker volume create [VOLUME_NAME] docker volume create [VOLUME_NAME] to list all the volumes docker volume ls to remove a volume docker volume rm [VOLUME_NAME] Docker networking to list all the docker networks docker network ls to create docker network docker network create [NETWORK_NAME] to connect a container to a specific docker network docker network connect [NETWORK_NAME] view details about specific docker network docker network inspect [NETWORK_NAME] Docker Compose start all the service defined in a yaml file docker-compose up stop and remove all servies defined in the file docker-compose down list all services managed by compose docker-compose ps Debugging and monitoring run a command inside a running container docker exec -it [container_id/name] View detailed information about a container or image docker inspect [container_id/name] monitor resource usage of container docker stats Clean up remove unused data(stopped container, images, networks) docker system prune remove unwanted containers docker container prune remove unused images docker image prune remove unused volume docker volume prune END
Docker Container
Docker Basics
- To know currently Running docker version
docker --version
- To get detailed information about docker installation
docker info
Working with Containers
- to run a docker container
# docker run [options] image-name [command] [args]
# ex.
docker run -d nginx
- to list running containers
docker ps
- to list all the containers running or stopped
docker ps -a
- to stop a running stop
# docker stop [container_id/name]
docker stop nginx
- to start a stopped container
# docker start [container_id/name]
docker start nginx
- to restart a container
# docker restart [container_id/name]
docker restart nginx
- to remove a stopped container
# docker rm [container_id/name]
docker rm nginx
- to check logs of a container
# docker logs [container_id/name]
docker logs nginx
Docker images
- to list all the docker images
docker images
- to download an image from docker hub
# docker pull [image_name]
docker pull nginx
- to build an image from a docker file
# docker build -t [IMAGE_NAME:TAG]
docker build -t
- to remove an docker image
# docker rmi [IMAGE_NAME:TAG
docker rmi nignx
Docker volume
- to create a docker volumes
# docker volume create [VOLUME_NAME]
docker volume create [VOLUME_NAME]
- to list all the volumes
docker volume ls
- to remove a volume
docker volume rm [VOLUME_NAME]
Docker networking
- to list all the docker networks
docker network ls
- to create docker network
docker network create [NETWORK_NAME]
- to connect a container to a specific docker network
docker network connect [NETWORK_NAME]
- view details about specific docker network
docker network inspect [NETWORK_NAME]
Docker Compose
- start all the service defined in a yaml file
docker-compose up
- stop and remove all servies defined in the file
docker-compose down
- list all services managed by compose
docker-compose ps
Debugging and monitoring
- run a command inside a running container
docker exec -it [container_id/name]
- View detailed information about a container or image
docker inspect [container_id/name]
- monitor resource usage of container
docker stats
Clean up
- remove unused data(stopped container, images, networks)
docker system prune
- remove unwanted containers
docker container prune
- remove unused images
docker image prune
- remove unused volume
docker volume prune