Docker Images
List all available Docker images on your system:
$docker images
Lists images:
$docker image ls
Download a Docker image from a repository:
$docker pull <image-name>
Push an image to a registry:
$docker push <image-name>
Remove a Docker image from your system:
$docker rmi <image-name>
Build a Docker image from a Dockerfile:
$docker build -t <image-name><path of dockerfile>
Build an image from a Dockerfile located in the current directory:
$docker build .
Create an image from a Dockerfile and tag it:
$docker build -t [name] : [tag] [dockerfile]
Tag an image:
$docker tag [image] : [tag]
Show history for an image:
$docker history [image]
Remove unused images:
$docker image prune
Clears all images that are not being used by containers:
$docker image prune -a
Removes all stopped containers, all networks not used by containers, all dangling images, and all build cache:
$docker system prune
Leaves a swarm:
$docker swarm leave
Removes a swarm:
$docker stack rm stack name
Docker Containers
Create and start a new container from a Docker image
$docker run <image-name>
List all running containers:
$docker ps
Stop a running container:
$docker stop <container-id>
Start a container:
$docker start <container-id>
Restart a running container:
$docker restart <container-id>
Pause process in a running container:
$docker pause <container-id>
Remove a stopped container from your system:
$docker rm <container-id>
Send a KILL signal to stop a container:
$docker kill <container-id>
Execute a command inside a running container:
$docker exec -it <container-id><command>
View the logs of a container:
$docker logs <container-id>
Run a container and remove it after it stops:
$docker run -rm <image>
Run an interactive process:
$docker run -it <image>
Inspects changes to directories and files in the container filesystem:
$docker diff container
Shows all running processes in an existing container:
$docker top container
docker top container:
$docker stats container
Docker Compose
Start containers defined in a Docker Compose file:
$docker-compose up
Stop and remove containers defined in a Docker Compose file:
$docker-compose down
Build or rebuild services defined in a Docker Compose file:
$docker-compose build
View the logs of a specific service defined in a Docker Compose file:
$docker-compose logs <service-name>
Docker Networks
List all available Docker networks:
$docker network ls
Create a new Docker network:
$docker network create <network-name>
Inspect details about a Docker network:
$docker network inspect <network-name>
Remove a Docker network:
$docker network rm <network name>
Docker Volumes
List all available Docker volumes:
$docker volume ls
Create a new Docker volume:
$docker volume create <volume-name>
Inspect details about a Docker volume:
$docker volume inspect <volume-name>
Remove a Docker volume:
$docker volume rm <volume-name>
Log in to a Docker registry:
$docker login
Log out of a Docker registry:
$docker logout
List low-level information on Docker objects:
$docker inspect [object]
Show the version of the local Docker installation:
$docker version
Display information about the system:
$docker info
Remove unused images, containers, and networks:
$docker system prune
Thank you for reading!!!!!!!!