Docker安装与运行

一、安装与启动

备份source.list,更新镜像链接

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

vim /etc/apt/sources.list

输入99dd删除所有,输入i插入,插入一下链接

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

保存后,更新

sudo apt-get update

添加使用 https 传输的软件包和 CA证书

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

添加软件源的 GPG 密钥

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

添加 docker 软件源

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

sudo apt-get update

安装 Docker CE

sudo apt-cache madison docker-ce

sudo apt-get install docker-ce docker-ce-cli containerd.io

启动

sudo service docker start

二、遇到问题

在Ubuntu中,很多小伙伴会遇到docker启动了但是使用service docker status 查看状态时都显示“Docker is not running”,这时,首先要检查一下在windows下是否将Ubuntu 的版本设置成2,如图


查看命令  wsl -l -v

设置命令 wsl --set-version Ubuntu-18.04 2

你可能感兴趣的:(Docker安装与运行)