Table of Contents
- To know currently Running docker version
docker --version
- To get detailed information about docker installation
docker info
- to get help with docker use
docker help
- to run a docker container
# docker run [options] image-name [command] [args]
# ex.
docker run nginx
# this will run container in detached mode
docker run -d nginx
- to list running containers
docker ps
- to list all the containers running or stopped
docker ps -a
# docker stop [container_id/name]
docker stop nginx
- to start a stopped container
# docker start [container_id/name]
docker start nginx
# 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
- to execute a command in a running container
docker exec -it [container_id] <command>
- to get detailed information about a container
docker inspect [container_id]
- to get real-time usage stats of a running container
docker stats
- to list all the docker images
docker images
- to download an image from docker hub
# docker pull [image_name]
docker pull nginx
- to push a docker image to a registry
docker push [image_name]
- to export docker image to a tar file we use
docker save -o <file>.tar [image_name]
- to import docker image from tar file
docker load -i <file>.tar
- to build an image from a docker file
# docker build -t [IMAGE_NAME:TAG]
docker build -t [image_name]
- to remove an docker image
# docker rmi [IMAGE_NAME:TAG
docker rmi nignx
- to create a docker volumes
# docker volume create [VOLUME_NAME]
docker volume create [VOLUME_NAME]
docker volume ls
docker volume rm [VOLUME_NAME]
- to mount a volume to a container
docker run -v <volume>:/path/in/container [image_name]
- to list all the docker networks
docker network ls
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]
- start all the service defined in a yaml file
docker-compose up
docker-compose logs
- build images defined in a docker-compose.yml file
docker-compose build
- stop and remove all servies defined in the file
docker-compose down
- list all services managed by compose
docker-compose ps
- 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
- remove unused data(stopped container, images, networks)
docker system prune -a
- remove unwanted containers
docker container prune
docker image prune -a
docker volume prune
END
Top comments (0)