Installation

Linux

Auto

# Download script
curl -fsSL https://get.docker.com -o install-docker.sh
 
# Verify script
cat install-docker.sh
 
# Run script
sudo sh install-docker.sh

Refer GitHub - docker/docker-install

Manual

The installation method varies slightly from platform to platform.
Summary:

  1. Add repository based on their platform
  2. Install Docker
sudo apt-get install \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin

Refer Docker - Install

Windows

Native

Docker does not provide a way to install just the Engine.
It has to be installed with Docker Desktop.

Refer Docker - Windows

WSL

An alternative way to install Docker Engine without Docker Desktop

  1. Install wsl
  2. Refer Linux

Usage

# Build the Docker image
docker build -t <image-tag> .
# Run the Docker container
arguments=(
    -d # Detach - Run in background
    -p 8080:8080 # Bind ports
    -e <environment-variables>
    --name <container-name>
    <image-tag>
)
 
docker run "${arguments[@]}"
# List containers (Verbose)
docker container list --all
 
# List containers (Consise)
docker ps --all
# Stop the Docker Container
docker stop <container-name>
# Remove the Docker Container
docker remove <container-name>
# Stop all containers (Verbose)
docker container stop $(docker container list --all --quiet)
 
# Stop all containers (Concise)
docker stop $(docker ps -a -q)
# Image Prunes
docker container prune --force
docker image prune --force --all
docker volume prune --force --all
 
# System Prunes
docker system prune --force --all
docker builder prune --force --all
# Backup Volume
# https://www.docker.com/blog/back-up-and-share-docker-volumes-with-this-extension
docker volume ls
docker run --rm -v <volume_name>:/data -v $(pwd):/backup alpine tar -czf /backup/backup.tar.gz -C /data .
# Build image for the specified architecture
docker build --platform linux/arm64 -t <image-name>:latest .
 
# Export image
docker save -o <image-name>.tar <image-name>:latest
 
# Load image
docker load < <image-name>.tar
 
# Run image
docker run --platform linux/arm64 --name <container-name> <image-name>:latest

Inconsistencies

Why there’s images but not containers?

docker image list
docker images
 
docker container list
docker containers # INVALID

Appendix