Docker Cheatsheet

Ronke AkinyemiRonke Akinyemi
2 min read

Docker Container Commands:

  1. Create a Container:

    docker create [OPTIONS] IMAGE [COMMAND] [ARG...]

  2. Start a Container:

    docker start [OPTIONS] CONTAINER

  3. Stop a Container:

    docker stop [OPTIONS] CONTAINER

  4. Remove a Container:

    docker rm [OPTIONS] CONTAINER

  5. List Running Containers:

    docker ps

  6. List All Containers(both stopped and running)

    docker ps -a

  7. Inspect a Container:

    docker inspect CONTAINER_ID

  8. List the port mappings for a container

    docker port CONTAINER_ID

  9. To view resource usage statistics for one or more container

    docker stats CONTAINER_ID

  10. To display the running processes inside a specified container

    docker top CONTAINER_ID

  11. Execute a Command in a Running Container:

    docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

  12. To remove all stopped containers

    docker container prune

Docker Image Commands:

  1. List Local Images:

    docker images

  2. Pull an Image from Docker Hub:

    docker pull IMAGE_NAME

  3. Remove an Image:

    docker rmi IMAGE_NAME

  4. Build an Image from Dockerfile:

    docker build [OPTIONS] PATH_TO_DOCKERFILE

  5. Save one or more Docker images to a tar archive file.

    docker save [OPTIONS] IMAGE [IMAGE...]

  6. Load Docker images from an archive file

    docker load [OPTIONS]

  7. Log in to Docker Hub:

    docker login

  8. Push an Image to Docker Hub:

    docker push IMAGE_NAME

  9. To remove unused or dangling images

    docker image prune

Docker Volume Commands:

  1. List Volumes:

    docker volume ls

  2. Create a Volume:

    docker volume create VOLUME_NAME

  3. Remove a Volume:

    docker volume rm VOLUME_NAME

Docker Network Commands:

  1. List Networks:

    docker network ls

  2. Create a Network:

    docker network create NETWORK_NAME

  3. Remove a Network:

    docker network rm NETWORK_NAME

Docker Compose Commands:

  1. Start Containers Defined in a Compose file:

    docker-compose up [OPTIONS]

  2. Stop Containers Defined in a Compose file:

    docker-compose down [OPTIONS]

  3. View Compose logs:

    docker-compose logs [SERVICE]

  4. List Containers:

    docker-compose ps

2
Subscribe to my newsletter

Read articles from Ronke Akinyemi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ronke Akinyemi
Ronke Akinyemi

DevOps Engineer