CheatSheet

https://docs.docker.com/engine/install/
Install using the apt repository
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get updateAnd last step
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugindocker -ddocker build -t <image-tag-name> <path-of-Dockerfile>docker run -ti <image-name> /bin/bashdocker run -d <image-name>docker exec -ti <container-name> bashdocker inspect <container-name> (or <container-id>)docker inspect --format {{.State.Pid}} <container-name-or-id>docker inspect --format='{{json .Volumes}}' <container-id> | python -mjson.tooldocker cp foo.txt mycontainer:/foo.txtdocker psdocker ps -adocker container prunedocker rm $(docker ps -qa)docker imagesdocker image ls -qdocker rmi $(docker images | grep "^<none>" | awk '{print $3}')docker volume prunedocker save -o <archive-name>.tar <image-name>docker load -i <archive-name>.tardocker image rm <image-name-or-id>docker image tag <image-name>:<tag-name> <image-name>:<new-tag-name>docker logindocker push <image-name>:<image-tag-name>docker network lsdocker network create "<network_name>"docker network connect "<network_id|name>" "<container_id|name>"docker network disconnect "<network_id|name>" "<container_id|name>"docker logs <container-id>docker run -p <localhost-port>:<container-port> <image-name>docker volume create <volume-name>docker volume inspect <volume-name>docker run -v <volume-name>:<folder-path-in-container> <image>docker run <image-name> -v $(pwd):<folder-path-in-container> <image>docker cp <container-id>:<path/to/file> <host/copy/path>docker cp <host/copy/path> <container-id>:<path/to/file>Manage Docker containers and images efficiently using the following commands. For more detailed documentation on specific subcommands, such as docker run, refer to the official Docker CLI documentation.
docker ps --allLists all Docker containers, both running and stopped.
docker run --name <container_name> <image>Starts a new container from the specified image with a custom name.
docker start|stop <container_name>Starts or stops the specified container.
docker pull <image>Downloads an image from a Docker registry to your local system.
docker imagesShows all images available locally.
docker exec -it <container_name> shAccesses an interactive shell in the specified running container.
docker rm <container_name>Deletes the specified stopped container.
docker logs -f <container_name>Displays the logs of the specified container and follows them in real-time.
Última actualización