Install and configure Docker in Ubuntu

Installation environment: Ubuntu 18.04

1. System Requirements###

The Ubuntu system's support for Docker is very mature, as long as it is 64-bit.
The minimum Ubuntu version currently supported by Docker is 14.04 LTS, but in terms of stability, it is recommended to use 16.04 LTS or 18.04 LTS version, and the newer the system kernel is, the better to support the latest features of Docker.

View detailed kernel version information: (choose one of the two) uname−a cat /proc/version

2. Add mirror source###

First, you need to install apt-transport-https and other software packages that support https protocol sources:

sudoapt−getupdate sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

Add the gpg key of the source:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-get add -
OK

Confirm the public key:

$ sudo apt-key fingerprint 0EBFCD88

Get the code name of the current operating system:

$ lsb_release -cs
bionic

Add the official software source of the Docker stable version: (note that the "bionic" section is consistent with the code name viewed)

$ sudo add-apt-erpository
“deb [arch=amd64] https://download.docker.com/linux/ubuntu
bionic stable”

After the addition is successful, update the apt package cache again:

$ sudo apt-get update

3. Start installing Docker

After adding the source, you can install the latest version of Docker. The package name is docker-ce, which represents the community version:

$ sudo apt-get install -y docker-ce

If there is an older version of Docker in the system, you will be prompted whether to delete it first, just select Yes.
After the installation is successful, the Docker service will be started automatically.
View docker information:

sudo docker version

4. Configure Docker service###

In order to avoid the need to switch to a privileged identity every time you use the Docker command, you can add the current user to the docker user group automatically created during the installation: (the USER_NAME part is the current user name)

sudo username -aG docker USER_NAME

The user updates the group information, it will take effect after logging out and logging in again.

The Docker service startup actually calls the dockerd command, which supports a variety of startup parameters. Therefore, the user can directly start the Docker service by executing the dockerd command, such as the following command to start the Docker service, enable the debug mode, and monitor the local port 2376:

$ dockerd -D -H tcp://127.0.0.1:2376

These options can be written into the daemon.json file under the /etc/docker/ path and read when the dockerd service starts:

{
  ”debug”: true,
  ”hosts”: [“tcp://127.0.0.1:2376”]
}

Of course, the operating system also encapsulates the Docker service. Taking Ubuntu as an example, the default configuration file of the Docker service is /etc/default/docker. You can modify the service startup parameters by modifying the DOCKER_OPTS, for example, let the Docker service open the network Monitoring on port 2375:

DOCKER_OPTS=”$DOCKER_OPTS -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock”

After modification, restart the Docker service through the service command:

sudo service docker restart

In addition, the download speed is slow when using a foreign mirror source. Modifying the mirror source can speed up the download speed. Switch to root privileges, open the /etc/docker/daemon.json file, and add the following content:

{
“registry-mirrors”: [
https://kfwkfulq.mirror.aliyuncs.com",
https://2lqq34jg.mirror.aliyuncs.com",
https://pee6w651.mirror.aliyuncs.com",
https://registry.docker-cn.com",
http://hub-mirror.c.163.com"
],
“dns”: [“8.8.8.8”,”8.8.4.4”]
}

In addition, if the service is abnormal, you can solve the problem by viewing the log information of the Docker service. On the Ubuntu system, you can execute journalctl -u docker.service

After restarting the Docker service each time, you can check the docker information (docker info command) to ensure that the service is running normally.

Recommended Posts

Install and configure Docker in Ubuntu
ubuntu install and configure GitLab
ubuntu18.04 install docker
Install and configure MySQL on Ubuntu
docker install ubuntu
Install and configure FreeIPA in Centos7
Install docker on ubuntu and basic usage
Deploy Docker and configure Nginx in CentOS
Linux install Docker and run Ubuntu system
Install docker on Ubuntu
Install python in Ubuntu
Install JDK in Ubuntu19.10
Install Docker on Ubuntu18
How to install and configure NATS on Ubuntu 16.04
Install JDK and configure environment variables on Ubuntu 16.04
How to install and configure Gogs on Ubuntu 18.04
How to install and configure Cyberpanel on Ubuntu 18.04
How to install and configure ownCloud on Ubuntu 16.04
How to install and configure GitLab on Ubuntu 18.04
How to install and use Docker on Ubuntu 20.04
How to install and configure Ansible on Ubuntu 18.04
How to install and configure Elasticsearch on Ubuntu 16.04
How to install and configure PostGIS on Ubuntu 14.04
How to install and configure VNC on Ubuntu 18.04
How to install and configure Sphinx on Ubuntu 16.04
How to install and configure OrientDB on Ubuntu 14.04
How to install and configure AppScale on Ubuntu 12.04
How to install and use Docker on Ubuntu 16.04
How to install and configure PostGIS on Ubuntu 14.04
Docker practice (1): install Docker on Ubuntu 16.04
Install VMware Tools in Ubuntu 18.04
Ubuntu 16.04 compile and install PHP 7.2
ubuntu18.04 compile and install python3.8
Centos6.5 install and configure mongodb
Ubuntu16.04 install SVN and configuration
Ubuntu16.04 install and uninstall VMware-Workstation 14
Install Docker on Ubuntu 18.04 offline
Install and configure Mono production environment on Ubuntu Server
Install and configure keepalived under CentOS 5.9
Install MySql with Docker in CentOS7
How to install mysql in Ubuntu 14.04
Docker ubuntu: install python-PIL-image environment on 14.04
ubuntu modify and configure ip address
Install and deploy Gerrit under Ubuntu
CentOS 8 - install and configure NFS service
Install nodejs and npm under Ubuntu 16.04
How to install memcache and start it in ubuntu environment
Install and use docker under CentOS 6.8
Install Centos7 operating system in Docker
How to compile and install PHP and Nginx in Ubuntu environment
How to install mysql in Ubuntu 14.04
CentOS Minimal install and configure TIPS
Nginx-ubuntu install Nginx and configure https
Compile and install QEMU under Ubuntu
Ubuntu uses Docker to install Gitlab
Detailed steps to install and configure k8s cluster in centos 7
FreeFileSync: Compare and synchronize files in Ubuntu
ubuntu Docker installation and deployment of Rancher
Install Gnome and VNC on Ubuntu Server
How to install Docker Compose on Ubuntu 18.04
Ubuntu install Elasticsearch and elasticsearch-analysis-ik word segmentation