【Docker】Ubuntu 18.04 安装Docker

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了【Docker】Ubuntu 18.04 安装Docker相关的知识,希望对你有一定的参考价值。

参考技术A 官方文档: https://docs.docker.com/engine/install/ubuntu/

docker的旧版本称为docker、docker.io或docker engine。如果已安装这些,请卸载它们:

如果apt-get报告没有安装这些软件包,那也没有关系。

1、更新apt包索引,安装包以允许apt通过 HTTPS 使用存储库

Update the apt package index and install packages to allow apt to use arepository over HTTPS:

2、添加Docker官方的GPG密钥

Add Docker’s official GPG key:

3、设置稳定存储库

Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

4、更新apt包索引,安装最新版本的Docker Engine和containerd

Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:

5、运行hello-world 镜像验证Docker Engine是否已正确安装

6、检测docker版本信息

输出以下内容:

Docker version 20.10.11, build dea9396

1、错误1:

执行以下指令:

报错:

忽略,继续执行下一条指令:

报错:

还是报错,没有办法继续。

解决办法:

编辑ubuntu源 /etc/apt/source.list

在页尾增加以下内容:

deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

重新执行安装指令:

2、错误2:

当添加新的源后,进行apt-get update后,可能会出现以下问题:

解决办法:

将公钥添加至服务器,即终端中输入:

添加成功后终端输出为:

重新执行安装指令:

问题解决,继续下一步安装。

win10 子系统 ubuntu 16.04 安装 docker

 

 

2,更新系统软件

$ sudo apt-get update

3,安装依赖包

$ sudo apt-get install     apt-transport-https     ca-certificates     curl     software-properties-common

4,添加官方密钥

执行该命令时,如遇到长时间没有响应说明网络连接不到docker网站,需要使用代-理进行。

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

显示OK,表示添加成功.

5,添加仓库

$ sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu    $(lsb_release -cs)    stable"

6,再次更新软件

经实践,这一步不能够省略,我们需要再次把软件更新到最新,否则下一步有可能会报错。

$ sudo apt-get update

7,安装docker

如果想指定安装某一版本,可使用 sudo apt-get install docker-ce=<VERSION>  命令,把<VERSION>替换为具体版本即可。

以下命令没有指定版本,默认就会安装最新版

$ sudo apt-get install docker-ce

8,查看docker版本

$ docker -v

显示“Docker version 17.09.0-ce, build afdb6d4”字样,表示安装成功。

 

在win10的子系统中,会发现服务无法启动,在日志 /var/log/docker.log有如下报错。

技术图片

 

查看服务状态 service docker status 为:

 * Docker is not running

 

解决方案:

 在/etc/fstab最后添加一行代码
none        /sys/fs/cgroup        cgroup        defaults    0    0

然后启动ubuntu终端窗口时,使用管理员身份运行,再执行  sudo service docker start  命令,即可正常运行服务。

 

ref: https://www.cnblogs.com/sweetsunnyflower/p/9862943.html
ref: https://www.jianshu.com/p/d1b2b4240256

以上是关于【Docker】Ubuntu 18.04 安装Docker的主要内容,如果未能解决你的问题,请参考以下文章

【Docker】Ubuntu 18.04 安装Docker

ubuntu18.04 安装docker

Ubuntu18.04 离线安装 docker

Linux(Ubuntu 18.04)安装Docker 社区(ce)版(图文并茂详细版!!!)

如何关闭或退出安装在我的 Ubuntu 18.04 中的 Docker?

Ubuntu 18.04安装Docker