Docker and Docker Compose Cheat Sheet¶
"Streamline your development with Docker and Docker Compose."
Welcome to the Docker and Docker Compose Cheat Sheet, tailored specifically for Ubuntu 22.04. This guide provides a streamlined approach to installing and managing Docker, a powerful platform for developing, shipping, and running applications inside lightweight containers.
Topics¶
Overview¶
- Title: "Docker and Docker Compose Cheat Sheet: Installing and Managing Docker on Ubuntu 22.04"
- Subtitle: "Installing and Managing Docker on Ubuntu 22.04"
- Tagline: "Streamline your development with Docker and Docker Compose."
- Description: "Quick guide on how to install Docker and Docker Compose on Ubuntu 22.04 to simplify your development workflow."
- Keywords: Docker, Docker Compose, Ubuntu, Installation, DevOps, Containerization
Cheat¶
# Docker and Docker Compose Cheat Sheet
- Subtitle: Installing and Managing Docker on Ubuntu 22.04
- Tagline: Streamline your development with Docker and Docker Compose.
- Description: Quick guide on how to install Docker and Docker Compose on Ubuntu 22.04 to simplify your development workflow.
- 5 Topics
## Topics
- Introduction to Docker: What is Docker?
- Installing Docker on Ubuntu 22.04: Step-by-step installation.
- Installing Docker Compose: Enhancing Docker with composition capabilities.
- Verifying Installation: How to check if Docker is running.
- Common Docker Commands: Essential commands for Docker usage.
Introduction to Docker¶
"Discover what Docker is and how it can benefit your development process."
Overview: Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files.
Installing Docker on Ubuntu 22.04¶
"Set up Docker on your Ubuntu system with these simple steps."
Installation Steps:
# Update system repositories and packages
sudo apt update
sudo apt upgrade -y
# Install required packages for Docker
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
# Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Set up the stable repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Engine
sudo apt update
sudo apt install docker-ce
# Check Docker status
sudo systemctl status docker
Installing Docker Compose¶
"Enhance your Docker experience with Docker Compose for multi-container environments."
Installation Steps:
# Create a directory for Docker CLI plugins
mkdir -p ~/.docker/cli-plugins/
# Download the specific release of Docker Compose
curl -SL https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
# Make the binary executable
chmod +x ~/.docker/cli-plugins/docker-compose
# Verify the installation
docker compose version
Verifying Installation¶
"Ensure Docker and Docker Compose are correctly installed and operational."
Verification Steps:
# Check Docker version
docker --version
# Check Docker Compose version
docker compose version
# Verify Docker is running
sudo systemctl status docker
Common Docker Commands¶
"Master these essential Docker commands to manage your containers effectively."
Basic Commands:
1. Starting a container:
bash
docker run hello-world
2. Listing containers:
bash
docker ps
docker ps -a # Includes stopped containers
3. Stopping a container:
bash
docker stop [CONTAINER_ID]
This cheat sheet is your quick reference to getting started with Docker and Docker Compose on Ubuntu 22.04, helping you to create a more efficient and controlled development environment. Whether you're deploying a single container or orchestrating a complex application with Docker Compose, these guidelines will aid in your development journey.