Deepin 15.11 installation docker-ce

Brief introduction

Docker is an open source application container engine that lets developers can package their applications as well as a portable container to the dependencies, and then posted to any popular Linux machine, can be virtualized. The container is full use of the sandbox mechanism will not have any interface with each other.

About Deepin in Docker

Deepin official application has been integrated warehouse docker, but not like this latest version of docker-ce. Since Deepin is based on the debian unstable version developed by $(lsb_release -cs)the acquired version information is unstable , and docker official sources did not support the debian unstable version, so use docker official tutorial is installed unsuccessful. If you need to install the docker-ce, please follow the steps below to install:

Docker way to install the latest version of the Deepin

  1. If you have previously installed the old version, be sure to uninstall the previous version

sudo apt-get remove docker.io docker-engine

  1. Key management and installation tools download
 // 密钥管理(add-apt-repository ca-certificates 等)与下载(curl 等)相关的工具
sudo apt-get install apt-transport-https ca-certificates curl python-software-properties software-properties-common

If there is no prompt python-software-properties, you can installsudo apt-get install software-properties-common

  1. Download and install the key

In view of the domestic network problems, it is strongly recommended to use domestic sources, please see the official source in comments.

Domestic source may be selected OSS station Tsinghua image or USTC open mirror sites , selected USTC example.

In order to confirm the legitimacy of the downloaded package, you need to add GPG key source software.

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -
// 官方源,能否成功可能需要看运气。
// curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
  1. View the key is successfully installed

sudo apt-key fingerprint 0EBFCD88

If the installation is successful, there will be the following:

  pub   4096R/0EBFCD88 2017-02-22              Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88  
  uid     Docker Release (CE deb) <[email protected]>  
  sub   4096R/F273FCD8 2017-02-22
  1. Add docker-ce source software in source.list in (please see the back of the Note ):
sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian wheezy stable"
// 官方源
// sudo add-apt-repository  "deb [arch=amd64] https://download.docker.com/linux/debian wheezy stable"

// 15.10 会提示  aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Deepin/stable
// 这里我们通过编辑 sudo vim /etc/apt/sources.list 添加一行即可,原因未知
sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian stretch stable"

Note: The official in wheezyuse position $(lsb_release -cs), but previously explained, running deepin where it gets is unstable , unstable Docker is not officially supported version! Therefore, the direct use of official tutorial command fail to install.

** Change Method: ** the above command version name wheezy, replace debian deepin based version of the corresponding code. View the version number of the command is: cat /etc/debian_version.

For example:

A). For deepin 15.5, I operate the above command is obtained debain version 8.0, debian 8.0 code-named Jessie , to replace the above wheezy into jessie, the docker can be properly installed.

. b) deepin 15.9.2 based on debian 9.0, debian 9.0, code-named for the Stretch , so deepin 15.9.2 on complete information to add:

sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian stretch stable"
  1. Update warehouse

sudo apt-get update

  1. Installation docker-ce

As the network is unstable, it may download failed. If the download fails, you can try more than once, or find a suitable time to continue.

sudo apt-get install docker-ce

After the files are installed in the unit startup error, see docker.service, the path is /lib/systemd/system/docker.service, the ExecStart = / usr / bin / dockerd -H fd: // amended as ExecStart = / usr / bin / dockerd, you can start docker normal

** Note: ** Tested in Deepin15.9 have been no changes are launched directly docker-ce

  1. Start docker:

systemctl start docker

  1. View the installed version information

docker version

  1. Verify docker is correctly installed and the normal use
sudo docker run hello-world

If you can not download, and can perform normal, then docker normal installation.

  1. So that ordinary users can run docker

By default, the average user will run docker rights issue, each run had to add sudo, a lot of trouble. Docker added to your account after the user group do not add the sudo:

sudo usermod -aG docker $USER

Users can log off and then log back on.

Replacement of domestic docker accelerator

If a docker official repository, the speed will be very slow, so replace domestic accelerator inevitable.

Method 1: Use the cloud Ali docker accelerator.

  1. Ali cloud for an account

Open the connection https://cr.console.aliyun.com/#/accelerator copy of your exclusive accelerator address.

  1. Modify the daemon configuration file used /etc/docker/daemon.json Accelerator (4 following commands is executed individually)

Note: Here https://jxus38ad.mirror.aliyuncs.com is the accelerator address of the applicant, this is only for demonstration purposes, but a user to fill in their own application accelerator addresses according to their own use.

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://jxus38ad.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

Second way: using a mirror source provided docker-cn

  1. /Etc/docker/daemon.json edit files, and enter the mirror source address docker-cn
sudo nano /etc/docker/daemon.json

Enter the following

{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}
  1. Restart docker Service
sudo service docker restart

Prohibiting boot from Kai

By default docker is boot from Kai, if we want to disable the boot from Kai, Deepin can be managed from the start by installing items chkconfig command:

# 安装chkconfig
sudo apt-get install chkconfig

# 移除自启
sudo chkconfig --del docker

Or use systemctl command.

Docker Service Management

Use systemctl command management

显示服务状态:systemctl status docker.service
列出服务层级和依赖关系:systemctl list-dependencies docker.service

启动服务:systemctl start docker.service
关闭服务:systemctl stop docker.service
重启服务:systemctl restart docker.service

设置服务自启动:systemctl enable docker.service
禁止服务自启动:sudo systemctl disable docker.service

查看服务是否自启动:systemctl is-enabled docker.service
列出系统所有服务的启动情况:systemctl list-units --type=service
列出所有自启动服务:systemctl list-unit-files|grep enabled

Corresponding old instruction (chkconfig, service)

显示服务状态:service docker status
列出服务层级和依赖关系:systemctl list-dependencies docker.service

启动服务:service docker start
关闭服务:service docker stop
重启服务:service docker restart

设置服务自启动:chkconfig --level 3 docker on
禁止服务自启动:chkconfig --level 3 docker off

查看服务是否自启动:chkconfig --list docker
列出系统所有服务的启动情况:chkconfig --list

E.g:

Set up services from the start

sudo systemctl enable docker.service

Synchronizing state of docker.service with SysV service 
script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
insserv: warning: current start runlevel(s) (empty) of 
script `docker' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of 
script `docker' overrides LSB defaults (0 1 6).

Check whether the service from the start

sudo systemctl is-enabled docker.service

enabled

Service is prohibited from the start

sudo systemctl disable docker.service

Synchronizing state of docker.service with SysV service 
script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable docker
insserv: warning: current start runlevel(s) (empty) of 
script `docker' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of 
script `docker' overrides LSB defaults (0 1 6).

Reference material

Deepin installation Docker
Linux - use systemctl command management services

发布了151 篇原创文章 · 获赞 47 · 访问量 23万+

Guess you like

Origin blog.csdn.net/e891377/article/details/103633421