Skip to content

Instantly share code, notes, and snippets.

@abenevaut
Last active July 31, 2024 23:24
Show Gist options
  • Save abenevaut/051d8fd214476eceab54d8f4b46da700 to your computer and use it in GitHub Desktop.
Save abenevaut/051d8fd214476eceab54d8f4b46da700 to your computer and use it in GitHub Desktop.

Let's follow together the Docker kata.

Here, the docker cheat sheet with popular commands.

# Create a container from an image
docker run --name my-container ubuntu:20.04
# Create and start a container that will remove itself after execution
docker run --rm --name my-container ubuntu:20.04
# Create and start a container in interactive mode
docker run -it --name my-container ubuntu:20.04
# Create and start a container in interactive mode that will remove itself after execution
docker run --rm -it --name my-container ubuntu:20.04
# Create and start a container in detached mode
docker run -d --name my-container ubuntu:20.04
# Execute a command in a container
docker exec my-container ls
# Execute a command in interactive mode in a container
docker exec -it my-container bash
# List running containers
docker ps
# List all containers
docker ps -a
# Stop a container
docker stop my-container
# Start a container
docker start my-container
# Remove a container
docker rm my-container
# Remove all unused containers
docker container prune
# Download an image from Docker Hub
docker pull ubuntu:20.04
# Build an image from a Dockerfile
docker build -t my-image .
# List downloaded images
docker images
# Remove an image
docker images rm ubuntu:20.04
# Remove all unused images
docker image prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment