⚡
usefultools.dev
🐳

Chuleta de Docker

NUEVO

Chuleta de Docker con comandos para imágenes, contenedores, opciones de run, logs, volúmenes, redes, builds, Dockerfile, Compose y limpieza. Con buscador y copia con un clic. Los comandos están en inglés.

Funciona al 100 % en tu navegador — lo que introduces nunca se sube ni se guarda en nuestros servidores.

95 entradas en 12 secciones

Images

  • docker images

    List local images.

  • docker pull <image>:<tag>

    Download an image from a registry.

  • docker rmi <image>

    Remove an image.

  • docker image ls --filter dangling=true

    List untagged ("dangling") images.

  • docker tag <image> <repo>:<tag>

    Give an image another name or tag.

  • docker history <image>

    Show the layers an image is made of.

  • docker save -o image.tar <image>

    Export an image to a tar file.

  • docker load -i image.tar

    Import an image from a tar file.

Containers

  • docker ps

    List running containers.

  • docker ps -a

    List all containers, including stopped ones.

  • docker start <container>

    Start a stopped container.

  • docker stop <container>

    Stop a container gracefully (SIGTERM, then SIGKILL after a timeout).

  • docker restart <container>

    Stop and start a container.

  • docker kill <container>

    Stop a container immediately.

  • docker rm <container>

    Remove a stopped container.

  • docker rm -f <container>

    Force-remove a container, even if running.

  • docker rename <old> <new>

    Rename a container.

  • docker stats

    Live CPU, memory and network use of containers.

Run & common flags

  • docker run <image>

    Create and start a container from an image.

  • docker run -d <image>

    Run in the background (detached).

  • docker run -it <image> sh

    Run interactively with a terminal and open a shell.

  • docker run --rm <image>

    Remove the container automatically when it exits.

  • docker run --name web <image>

    Give the container a name.

  • docker run -p 8080:80 <image>

    Publish container port 80 on host port 8080.

  • docker run -e KEY=value <image>

    Set an environment variable.

  • docker run --env-file .env <image>

    Load environment variables from a file.

  • docker run -v mydata:/data <image>

    Mount a named volume into the container.

  • docker run --network mynet <image>

    Attach the container to a network.

  • docker run --restart unless-stopped <image>

    Restart automatically unless you stopped it yourself.

  • docker run -m 512m --cpus 1 <image>

    Limit memory and CPU.

Exec, logs & copy

  • docker exec -it <container> sh

    Open a shell inside a running container (use bash if the image has it).

  • docker exec <container> <command>

    Run one command in a running container.

  • docker logs <container>

    Show a container's logs.

  • docker logs -f --tail 100 <container>

    Follow the log, starting with the last 100 lines.

  • docker top <container>

    List processes inside a container.

  • docker cp <container>:/path/file .

    Copy a file from a container to the current folder.

  • docker cp ./file <container>:/path/

    Copy a local file into a container.

  • docker attach <container>

    Attach your terminal to the main process of a container.

Volumes

  • docker volume create <name>

    Create a named volume.

  • docker volume ls

    List volumes.

  • docker volume inspect <name>

    Show details of a volume, including where it is stored.

  • docker volume rm <name>

    Delete a volume and its data.

  • docker run -v "$(pwd)":/app <image>

    Bind-mount the current folder into the container (macOS, Linux, Git Bash).

  • docker run -v mydata:/data:ro <image>

    Mount a volume read-only.

Networks

  • docker network ls

    List networks.

  • docker network create <name>

    Create a user-defined bridge network (containers can reach each other by name).

  • docker network inspect <name>

    Show which containers are on a network and their IPs.

  • docker network connect <network> <container>

    Attach a running container to a network.

  • docker network disconnect <network> <container>

    Detach a container from a network.

  • docker port <container>

    Show published ports of a container.

Build

  • docker build -t myapp:1.0 .

    Build an image from the Dockerfile in this folder and tag it.

  • docker build -f Dockerfile.prod -t myapp .

    Build from a Dockerfile with another name.

  • docker build --no-cache -t myapp .

    Build without using the layer cache.

  • docker build --build-arg VERSION=1 -t myapp .

    Pass a build argument declared with ARG.

  • docker buildx build --platform linux/amd64,linux/arm64 -t myapp .

    Build for several CPU architectures with BuildKit.

Dockerfile instructions

  • FROM node:22-alpine

    Base image to start from.

  • WORKDIR /app

    Set the working directory for the next instructions.

  • COPY package*.json ./

    Copy files from the build context into the image.

  • RUN npm ci

    Run a command while building the image.

  • ENV NODE_ENV=production

    Set an environment variable that stays in the image.

  • ARG VERSION=1

    Define a variable available only at build time.

  • EXPOSE 3000

    Document the port the app listens on (does not publish it).

  • USER node

    Run the following instructions and the container as this user.

  • ENTRYPOINT ["node"]

    The fixed program the container runs.

  • CMD ["server.js"]

    Default arguments or command, easy to override at run time.

  • FROM node:22 AS build

    Start a named stage for a multi-stage build.

  • COPY --from=build /app/dist ./dist

    Copy files from an earlier build stage.

Compose

Uses the "docker compose" plugin (older installs have docker-compose).

  • docker compose up

    Create and start the services in docker-compose.yml.

  • docker compose up -d --build

    Rebuild images and start in the background.

  • docker compose down

    Stop and remove containers and networks.

  • docker compose down -v

    Same, and also delete the named volumes.

  • docker compose ps

    List the containers of the project.

  • docker compose logs -f <service>

    Follow the logs of a service.

  • docker compose exec <service> sh

    Open a shell in a running service.

  • docker compose pull

    Pull the newest images for the services.

  • docker compose config

    Validate the file and print the final configuration.

Registry

  • docker login

    Log in to Docker Hub.

  • docker login <registry-host>

    Log in to another registry.

  • docker push <repo>/<image>:<tag>

    Upload an image to a registry.

  • docker search <term>

    Search Docker Hub for images.

  • docker logout

    Remove stored registry credentials.

Prune & cleanup

These delete data. Read the prompt before you confirm.

  • docker system df

    Show disk space used by images, containers and volumes.

  • docker container prune

    Remove all stopped containers.

  • docker image prune

    Remove dangling images.

  • docker image prune -a

    Remove all images not used by a container.

  • docker volume prune

    Remove volumes not used by any container.

  • docker network prune

    Remove unused networks.

  • docker system prune

    Remove stopped containers, unused networks, dangling images and build cache.

Inspect & formatting

  • docker inspect <container>

    Show the full JSON details of a container or image.

  • docker inspect -f '{{.State.Status}}' <container>

    Print one field using a Go template.

  • docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container>

    Print the container IP address.

  • docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'

    Custom columns for docker ps.

  • docker ps -q

    Print only container IDs, useful in scripts.

  • docker version

    Show client and server versions.

  • docker info

    Show system-wide information about the Docker daemon.

⚡

Ejemplos rápidos

Entradas típicas y los resultados que produce esta herramienta.

Run
Publicar el puerto 80 en el puerto 8080 del host
docker run -p 8080:80 <image>
Exec
Abrir una shell en un contenedor
docker exec -it <container> sh
Logs
Seguir las últimas 100 líneas del log
docker logs -f --tail 100 <container>
Compose
Detener y eliminar un stack de Compose
docker compose down
📖

Descripción general

Docker empaqueta una aplicación y sus dependencias en una imagen que se ejecuta igual en cualquier máquina. Esta chuleta de Docker recoge los comandos que más se usan: gestión de imágenes y contenedores, opciones de run, exec y logs, volúmenes, redes, builds, instrucciones de Dockerfile, Docker Compose, registros y limpieza.

Los comandos que eliminan datos, como prune y compose down -v, llevan un aviso claro (en inglés). Una sección final muestra cómo leer un campo con inspect y una cadena de formato de plantilla de Go. Los ejemplos usan la forma actual del plugin docker compose.

Los comandos, las opciones y sus descripciones breves se muestran en inglés, tal como los verás en la terminal; solo el texto de la página y la interfaz están traducidos. Filtra la lista, copia un comando y sustituye los marcadores como <container>. Todo se ejecuta en tu navegador y nada de lo que escribes se sube.

¿Por qué usar esta herramienta?

  • Encuentra el comando de docker adecuado con rapidez
  • Opciones de run explicadas una a una
  • Instrucciones de Dockerfile en un solo lugar
  • Comandos de limpieza con avisos claros
  • Copia cualquier comando con un clic
⭐

Funciones

📦

Imágenes y contenedores

Descarga, lista, inicia, detiene, elimina y renombra con las opciones habituales.

🚩

Opciones de run

-d, -it, --rm, -p, -e, -v, --network, --restart y límites de recursos.

📜

Dockerfile

FROM, COPY, RUN, ENV, EXPOSE, ENTRYPOINT, CMD y la sintaxis multietapa.

🧩

Compose

up, down, logs, exec, pull y config para proyectos con varios servicios.

🧹

Limpieza

Comprueba el uso de disco y elimina contenedores, imágenes, volúmenes y redes sin usar.

🔬

Formatos de inspect

Extrae un solo valor de docker inspect con una plantilla de Go.

🛠️

Cómo se usa

1

Elige una sección

Desplázate hasta Containers, Volumes, Build o el tema que necesites (los títulos de sección están en inglés).

2

O filtra

Escribe una palabra como «logs» o «prune» en el cuadro «Filtrar esta chuleta».

3

Revisa la descripción

Lee qué hace cada comando (la descripción está en inglés), sobre todo los de limpieza.

4

Copia y ejecuta

Pulsa Copiar, pega en tu terminal y sustituye los marcadores como <image>.

🤔

Preguntas frecuentes