docker安装

 参考:https://www.runoob.com/docker/ubuntu-docker-install.html

 

1 安装

1.1 方式1: 官方安装脚本进行安装

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

或者 也可以使用国内 daocloud 一键安装命令:

curl -sSL https://get.daocloud.io/docker | sh

1.2 方式2:手动安装

1、卸载就版本

$ sudo apt-get remove docker docker-engine docker.io containerd runc

2、安装依赖包

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

 

3、添加仓库

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

4、添加密钥

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

5、更新apt 包索引

$ sudo apt-get update

6、安装docker

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

7、Docker 作为非 root 用户

$ sudo usermod -aG docker your-user

8、注销后重新登陆

 

9、设置国内加速镜像地址

 

1、新建或修改  /etc/docker/daemon.json , 内容如下

 

{

    "registry-mirrors": [

        "https://docker.mirrors.ustc.edu.cn",

        "https://hub-mirror.c.163.com",

        "https://mirror.ccs.tencentyun.com"

    ]

 

}

 

2、重新启动docker

 

sudo systemctl daemon-reload
sudo systemctl restart docker

 

10、测试docker 打印出以下信息则安装成

$ sudo docker run hello-world

 Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world

 

posted @ 2022-02-12 19:24  张志伟122  阅读(29)  评论(0编辑  收藏  举报