Deepin 20.7 系统安装docker&docker-compose

一、安装docker

1、更新仓库

sudo apt-get update

2、安装apt依赖

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

3、添加官方密钥

$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -

4、设置docker稳定版仓库

$ sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian \
  $(lsb_release -cs) \
  stable"

5、步骤4报错,未报错直接进入步骤7

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 95, in 
    sp = SoftwareProperties(options=options)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py                                                                          ", line 109, in __init__
    self.reload_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py                                                                          ", line 599, in reload_sourceslist
    self.distro.get_sources(self.sourceslist)
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 93, in get_s                                                                          ources
    (self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distributi                                                                          on template for Deepin/apricot

6、在最后一行添加源地址,然后更新仓库,出现命中、buster等字样即为成功

 sudo vim /etc/apt/sources.list
deb [arch=amd64] https://download.docker.com/linux/debian buster stable
sudo apt-get update

7、安装 Docker Engine-Community

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

8、启动docker,设置开启自启动,设置权限

sudo systemctl start docker
systemctl enable docker.service
sudo groupadd docker
sudo usermod -aG docker $USER
# 输入以上命令之后,需要退出终端,重新进入

9、设置国内镜像库

创建或修改 /etc/docker/daemon.json 文件,修改为如下形式

{
    "registry-mirrors": [
        "https://registry.cn-hangzhou.aliyuncs.com",
        "http://hub-mirror.c.163.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.docker-cn.com"
    ]
}

重新启动docker

sudo systemctl restart docker

查看是否成功,在尾部看见Registry Mirrors为刚设置的地址即为成功

docker info

二、安装docker-compose

su # 进入root
curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
exit # 退出root
sudo chmod +x /usr/local/bin/docker-compose

你可能感兴趣的:(docker,linux)