Docker Configuration Scripts

Updated: 03 September 2023

Docker Configuration Scripts

Ubuntu

Run the following as sudo on an Ubuntu VM or WSL as per the instructions on the Docker CE site

Terminal window
1
sudo apt-get update
2
sudo apt-get install \
3
apt-transport-https \
4
ca-certificates \
5
curl \
6
gnupg-agent \
7
software-properties-common -y
8
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
9
sudo apt-key fingerprint 0EBFCD88
10
sudo add-apt-repository \
11
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
12
$(lsb_release -cs) \
13
stable"
14
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
15
sudo docker run hello-world

WSL

Take a look here

Note that WSL cannot independantly run the Daemon, but you can connect to the instance of Docker Daemon on your Windows system

Terminal window
1
# Update the apt package list.
2
sudo apt-get update -y
3
4
# Install Docker's package dependencies.
5
sudo apt-get install -y \
6
apt-transport-https \
7
ca-certificates \
8
curl \
9
software-properties-common
10
11
# Download and add Docker's official public PGP key.
12
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
13
14
# Verify the fingerprint.
15
sudo apt-key fingerprint 0EBFCD88
16
17
# Add the `stable` channel's Docker upstream repository.
18
#
19
# If you want to live on the edge, you can change "stable" below to "test" or
20
# "nightly". I highly recommend sticking with stable!
21
sudo add-apt-repository \
22
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
23
$(lsb_release -cs) \
24
stable"
25
26
# Update the apt package list (for the new apt repo).
27
sudo apt-get update -y
28
29
# Install the latest version of Docker CE.
30
sudo apt-get install -y docker-ce
31
32
# Allow your user to access the Docker CLI without needing root access.
33
sudo usermod -aG docker $USER

Lastly in order to tell WSL where your Docker Daemon is running (assuming you’ve exposed it from Docker Desktop on Windows) you need to run the following

Terminal window
1
docker -H localhost:2375 images