Docker 19+Ubuntu 18.04 Install StepByStep

Part1.Install Ubuntu 18.04 Desktop

Virtual Machine Environment: VMWare Workstation 15
Virtual Machine Configuration: 1cpu 4 core 8G memory 40G hard disk (immediate space allocation + single file)
Virtual Machine Network: NAT Network

1.1 Create Virtual Machine

  • step1.

    Figure 1-1 Install the system later

  • step2. Select Operating System

    Figure 1-2 ubuntu64 bit

  • Step 3. Select CPU

    Figure 1-3 Select CPU

  • step4 selects memory 8192 (omitted), using the network as NAT

    Figure 1-4 Network type is NAT

  • step5 IO type, disk type is recommended

  • step6 disk type to improve performance, choose to allocate space immediately

    Figure 1-6 Allocate disks immediately

  • Step 7 proceeds to the next step, confirms the specifications, and clicks Custom Hardware

    Figure 1-7 Custom Hardware

    Figure 1-8 Select to install a mirror guide disc

    After setting iso, close the window, click Finish, and start the virtual machine.

1.2 Installation System

Figure 1.2-1 Install Ubuntu

Select the smallest installation, do not check to download updates!

Figure 1.2-2 Installation type selection

Next, select the default settings, erase the disk, confirm, and proceed to the installation process.

Figure 1.2-3 Formatting disk reminders

Next, select the time zone, default shanghai Hai, Next, create a user account

Figure 1.2-4 Account creation

After the installation is complete, restart the virtual machine and proceed to the next configuration step.

Part2. Configure Ubuntu

There are several main steps to configuring ubuntu

  1. Install openssh-server

  2. Configure apt Software Warehouse Domestic Mirror

  3. Configure the network, turn off the firewall

  4. vmtools installation

Note: 18's ubuntu GUI is not very friendly to vmware compatibility. It is recommended to change the resolution manually before executing the command

Change Resolution

The following steps explain:

2.1 Install openssh-server

The default ubuntu desktop version does not have ssh server installed, so we must install it first.
Update apt software library before performing installation

sudo apt-get update
sudo apt-get install openssh-server

Figure 2.1-1 Successful installation of ssh-server

Check the current network IP address because it is NAT and the address is dynamically acquired.
Execute Network Command View

ip a

Figure 2.1-2 Obtains the IP address

Log in using an ssh client such as putty on the host desktop to configure the following.
Note: ssh logon user is the user created at installation time, root user is not enabled yet

2.2 Configure apt-get domestic mirror station

su@su-ubu18:~$  sudo vi /etc/apt/sources.list

Mirror file:

#Default comment source mirroring to improve apt update speed, uncomment if needed
deb bionic main restricted universe multiverse
# deb-src bionic main restricted universe multiverse
deb bionic-updates main restricted universe multiverse
# deb-src bionic-updates main restricted universe multiverse
deb bionic-backports main restricted universe multiverse
# deb-src bionic-backports main restricted universe multiverse
deb bionic-security main restricted universe multiverse
# deb-src bionic-security main restricted universe multiverse
#Pre-release software source, not recommended
# deb bionic-proposed main restricted universe multiverse
# deb-src bionic-proposed main restricted universe multiverse
deb bionic main restricted universe multiverse
deb bionic-security main restricted universe multiverse
deb bionic-updates main restricted universe multiverse
deb bionic-proposed main restricted universe multiverse
deb bionic-backports main restricted universe multiverse
#Similar to Tsinghua Mirror Source, source mirroring is commented out to speed up apt update. Uncomment if necessary
# deb-src xenial main restricted universe multiverse 
# deb-src xenial-security main restricted universe multiverse 
# deb-src xenial-updates main restricted universe multiverse 
# deb-src xenial-proposed main restricted universe multiverse 
# deb-src xenial-backports main restricted universe multiverse

After editing, wq save is available

#Update apt
sudo apt-get update

2.3 Configure your network, turn off your firewall

Be careful:
The ubuntu 18 version of network configuration abandons traditional methods and introduces the form of yaml configuration files
Network configuration method:
Open and edit the yaml configuration file

sudo vi /etc/netplan/01-network-manager-all.yaml

Configured as follows (static IP, gateway vmware NAT gateway address):

# Let NetworkManager manage all devices on this systemnetwork:
      -      dhcp4: false
      gateway4:      nameservers:
        addresses: []
        search: [localdomain]
  version: 2
  renderer: networkd

Be careful:
renderer here, the system defaults to NetworkManager, if not modified,
The NetworkManager configuration network will be enabled, then the DNS configuration section will need to enter the GUI configuration to take effect
Enable netplan command to apply configuration after configuration is saved

sudo netplan apply

Close Firewall
For practice convenience, we turn off the firewall service, docker uses iptables, so we just turn off ufw

sudo systemctl disable ufw && sudo systemctl stop ufw

2.4 Install vmtools

Here we install the official tools of vmware directly, and mount tools from the virtual machine to the CD-ROM directory automatically
/media/[user name]
Enter VMware Tools folder to copy CD-ROM files
To User Directory

su@su-virtual-machine: cp VMwareTools-10.3.10-12406962.tar.gz ~/


su@su-virtual-machine:/media/su/VMware Tools$: cd ~
su@su-virtual-machine:~$ tar -xvf VMwareTools-10.3.10-12406962.tar.gz

Enter the directory to perform the installation

su@su-virtual-machine:~/vmware-tools-distrib$ sudo ./

open-vm-tools packages are available from the OS vendor and VMware recommends
using open-vm-tools packages. See for more
Do you still want to proceed with this installation? [no]

Enter yes to proceed with installation and get prompted to return to default.
When the host file share is last prompted, select no
The VMware Host-Guest Filesystem allows for shared folders between the host OS
and the guest OS in a Fusion or Workstation virtual environment.  Do you wish
to enable this feature? [yes]
Next, proceed to Enter by default and install successfully.

You must restart your X session before any mouse or graphics changes take

To enable advanced X features (e.g., guest resolution fit, drag and drop, and
file and text copy/paste), you will need to do one (or more) of the following:
1. Manually start /usr/bin/vmware-user
2. Log out and log back into your desktop session
3. Restart your X session.
--the VMware team

Part3. Install docker

There are several main steps to install docker:

  1. Update mirror warehouse apt-get update

  2. Install https to support related components

  3. Add Docker's official GPG key

  4. Set up docker stable repository

  5. Install docker-ce

3.1 Update Mirror

sudo apt-get update

3.2 Install https-related components

su@su-virtual-machine:~/vmware-tools-distrib$  sudo apt-get install \
  apt-transport-https \
  ca-certificates \
  curl \

Encountered a configuration interface, select yes

libssl Configuration Wizard

3.3 Add Docker's official GPG key

$ curl -fsSL | sudo apt-key add -

Verify the correctness of the key fingerprint:
By searching the last eight characters of the fingerprint, confirm that you now have the key to the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

$ sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <>
sub   rsa4096 2017-02-22 [S]

3.4 Setting up a docker stable repository

Set up a stable version of the docker repository according to the following commands

$ sudo add-apt-repository \
   "deb [arch=amd64] \
   $(lsb_release -cs) \

#Refresh the mirror apt repository until the following information appears:
Fetched 327 kB in 1s (231 kB/s)
Reading package lists... Done

3.5 Install Docker-CE version (latest version)

Update warehouse first

$ sudo apt-get update

Install the latest version of docker-ce

$ sudo apt-get install docker-ce

When prompted, return by default.
After installation, check that the docker service is started

$ systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
   Active: active (running) since Fri 2020-03-13 04:57:44 CST; 30s ago

$ sudo docker -v
Docker version 19.03.8, build afacb8b7f0

Congratulations, docker installation is over!!
Next, configure docker mirror warehouse acceleration!!

Part 4. Configure the Docker environment

For reasons you know, docker's mirror warehouse is very slow to access in China, thanks to the speed-up service provided by major domestic Internet agencies.
Currently available mirror sites are:
Note: Mirror Acceleration of Ali Cloud suggests configuring your own Acceleration URL with your Ali Cloud account
Access to Aliyun address:
Configure your own acceleration URL
It is recommended that you configure the accelerated image using the configuration file method

$ mkdir -p /etc/docker
$sudo tee /etc/docker/daemon.json <<-'EOF'
  "registry-mirrors": [""]

Restart docker service after configuration is complete

sudo systemctl daemon-reload
sudo systemctl restart docker

Test docker

Here's a test using the hello-world mirror

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

Wonderful!! Successful!!

Next, throw away sudo before docker

Since docker daemon requires a Unix socket bound to the host instead of a regular TCP port, and the Unix socket is owned by the root user, other users can only perform the operation by adding the sudo option before the command.
so, let's configure:

  1. Create a docker group

$ sudo groupadd docker
  1. Add current user to docker group

$ sudo usermod -aG docker $USER
  1. Exit the shell and log in again

  2. Verify docker

$ docker run -d -p 8080:80 httpd
Unable to find image 'httpd:latest' locally
latest: Pulling from library/httpd
68ced04f60ab: Pull complete
35d35f1e0dc9: Pull complete
8a918bf0ae55: Pull complete
d7b9f2dbc195: Pull complete
d56c468bde81: Pull complete
Digest: sha256:946c54069130dbf136903fe658fe7d113bd8db8004de31282e20b262a3e106fb
Status: Downloaded newer image for httpd:latest

Success, Again!

Bingo!! Enjoy it!

Some of the above are from the Internet. To discuss cloud computing, Docker, Kubernetes, etc.
Kegaqun discussed with me: 1038340570 (Transportation and Maintenance Base)

Tags: Linux Docker Ubuntu sudo Vmware

Posted on Fri, 13 Mar 2020 14:41:04 -0400 by hedgehog90