Setup
This page explains how to install Docker.
Linux
You can follow the instruction on https://docs.docker.com/engine/install/ubuntu/.
1. Install Docker Engine
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
2. Verify installation
sudo docker run hello-world
Mac
You need to install a virtual machine to run Docker on Mac. (Installing Docker Desktop or Rancher Desktop takes care of this.)
1. Install Docker
brew install --cask docker
2. Install Docker Desktop or Rancher Desktop
You can follow this link to install Docker Desktop (might need a paid subscription). Otherwise, you can choose to install Rancher Desktop (free).
Ensure that you have followed their installation step (i.e. by click-and-dragging their application's icon to your Applications folder).
If you use Rancher Desktop: Open the app, go to Kubernetes Settings, and ensure you choose "dockerd" for the Container Runtime.
3. Verify installation
Try running the following:
sudo docker run hello-world
# Unable to find image 'hello-world:latest' locally
# latest: Pulling from library/hello-world
# 7050e35b49f5: Pull complete
# Digest: sha256:13e367d31ae85359f42d637adf6da428f76d75dc9afeb3c21faea0d976f5c651
# Status: Downloaded newer image for hello-world:latest
# Hello from Docker!
# This message shows that your installation appears to be working correctly.
# ...
If it fails, try the troubleshooting below.
4. Troubleshooting
Ensure that your VM or Rancher Desktop is running. If you use Rancher Desktop, ensure that you have chosen "dockerd" for the Container Runtime.
If you see error like docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
, check your docker context:
docker context ls
# NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
# default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock https://6E4A4AC9E64703A206C54E673154A8C1.sk1.ap-southeast-1.eks.amazonaws.com (default) swarm
See if the socket file such as /var/run/docker.sock
exists:
ls /var/run/docker.sock
If it doesn't check the socket of Rancher Desktop:
which docker
# /Users/ferdinand.antonius/.rd/bin/docker
ls /Users/ferdinand.antonius/.rd
# bin docker.sock
Create a new docker context and use that new context
docker context create rancher-desktop --docker host=unix:///Users/ferdinand.antonius/.rd/docker.sock\
# Successfully created context "rancher-desktop"
docker context use rancher-desktop
# Current context is now "rancher-desktop"
References
- Install Docker Engine on Ubuntu — https://docs.docker.com/engine/install/ubuntu/
- Cannot connect to the Docker daemon on macOS — https://stackoverflow.com/questions/44084846/cannot-connect-to-the-docker-daemon-on-macos
- Install Docker on Mac M1 without Docker Desktop — https://dev.to/sergej_brazdeikis/install-docker-on-mac-m1-without-docker-desktop-k6o
- Docker Context — https://docs.docker.com/engine/context/working-with-contexts/