Docker Lab Setup - jacob-dinapoli/tech-journal GitHub Wiki
Using netplan to configure a static IP address
- Netplan is a new network configuration utility that was introduced in Ubuntu 17.10 that reads the YAML file and generates all the confirguration for renderer tool (NetworkManager or networkd).
Netplan reads network configuration from /etc/netplan/*.yaml.
First, remove the ifupdown package so that we can use netplan to configure network interfaces.
apt remove ifupdown
In Ubuntu 18.04 server, cloud-init manages the network configuration. So, you would need to disable it by editing the below file.
nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Put the below line into the configuration file.
network: {config: disabled}
Move any files present in /etc/netplan directory to other location.
mv /etc/netplan/* /root
Now, we will create a netplan configuration for the network interface. I recommend you to use vim apt install vim editor for auto syntax.
vim /etc/netplan/01-network-card.yaml
Use the below configuration file.
ETHERNET:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
search: [itzgeek.local]
addresses: [192.168.1.1,8.8.8.8]
Install Docker
Follow the instructions for steps 1-3 on https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04
Step 1 — Installing Docker
The Docker installation package available in the official Ubuntu repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository. To do that, we’ll add a new package source, add the GPG key from Docker to ensure the downloads are valid, and then install the package.
First, update your existing list of packages:
sudo apt update
Next, install a few prerequisite packages which let apt use packages over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Then add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Next, update the package database with the Docker packages from the newly added repo:
sudo apt update
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
apt-cache policy docker-ce
You’ll see output like this, although the version number for Docker may be different: Output of apt-cache policy docker-ce
docker-ce:
Installed: (none)
Candidate: 18.03.1ce3-0ubuntu
Version table:
18.03.1ce3-0ubuntu 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
Notice that docker-ce is not installed, but the candidate for installation is from the Docker repository for Ubuntu 18.04 (bionic).
Finally, install Docker:
sudo apt install docker-ce
Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:
sudo systemctl status docker
The output should be similar to the following, showing that the service is active and running:
Output
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-07-05 15:08:39 UTC; 2min 55s ago
Docs: https://docs.docker.com
Main PID: 10096 (dockerd)
Tasks: 16
CGroup: /system.slice/docker.service
├─10096 /usr/bin/dockerd -H fd://
└─10113 docker-containerd --config /var/run/docker/containerd/containerd.toml
Installing Docker now gives you not just the Docker service (daemon) but also the docker command line utility, or the Docker client. We’ll explore how to use the docker command later in this tutorial.