Docker is a tool that simplifies the process of managing application processes in containers. Containers allow you to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.
Containers let you run your applications in resource-isolated processes, allowing them to be portable between different systems. Containers are similar to virtual machines, but containers are more portable, more resource-friendly, and more dependent on the host operating system.
1. Install Docker
In your Linux Virtual Desktop, open the terminal and update the existing list of packages:
sudo apt update
Next, install prerequisite packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Then add the GPG key for the official Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Next, update the package database with the Docker packages:
sudo apt update
Finally, install Docker:
sudo apt install docker-ce
2. Configure Docker to use a proxy
In Virtual Desktops, access to the Internet is restricted, so you need to configure Docker to use a proxy.
Create a systemd drop-in directory for the docker service:
sudo mkdir /etc/systemd/system/docker.service.d
In this new directory, create
sudo nano /etc/systemd/system/docker.service.d/proxy.conf
The command will open nano editor in the terminal. Paste the following content, and then click Ctrl+S, Ctrl+X:
[Service] Environment="HTTPS_PROXY=http://10.0.0.5:3128" "NO_PROXY=localhost,127.0.0.1,::1"
Restart the Docker service:
sudo systemctl daemon-reload sudo systemctl restart docker
3. Use Docker without sudo
In order to avoid typing
sudo whenever you run the docker command, add
workspace user to the docker group:
sudo usermod -aG docker workspace
For changes to take effect, you must restart the VM.
4. Test the installation
Check whether you can access and download images from the Docker Hub:
docker run hello-world
The output will indicate whether Docker is working correctly: