ubuntu安装docker(测试:ubuntu 18.4)

简介:

ubuntu安装很简单,就直接放操作了。

附加:快速搭建各种漏洞环境(Various vulnerability environment) https://github.com/Medicean/VulApps
ubuntu16.4或18.4前期的源和系统准备可以参照:https://blog.csdn.net/lm2017/article/details/101985812

操作:


1.删除原先的docker(默认没有)
 sudo apt-get remove docker docker-engine docker.io containerd runc

2.添加 Docker 的官方 GPG 密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -


3.验证您现在是否拥有带有指纹的密钥
sudo apt-key fingerprint 0EBFCD88


4.设置稳定版仓库
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"


5. 安装最新的Docker-ce 
 sudo apt-get update
sudo apt-get install docker-ce


6.apt-get install docker-ce可能会出现的问题,无问题直接跳过
可能会发生下面的提示:
    无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用)
    无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它?
解决办法如下:
(1)终端输入 ps  aux ,列出进程。找到含有apt-get的进程,直接sudo kill PID。(应该会kill把)
(2)强制解锁,命令
    sudo rm /var/cache/apt/archives/lock
    sudo rm /var/lib/dpkg/lock
完成后重新 sudo apt-get install docker-ce

7.配置docker镜像加速
sudo curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://d1c9c786.m.daocloud.io
sudo systemctl restart docke



问题附加:

1.用Hello World校验Docker的安装

sudo docker run hello-world

如果出现Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world
d1725b59e92d: Pull complete 

不要慌,服务器从Docker Hub获取到最新的Hello World镜像,下载到本地。

再次输入docker run hello-world,回车:

Hello from Docker.
This message shows that your installation appears to be working correctly.

2.Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate is valid for drivefca.com, www.drivefca.com, not registry-1.docker.io(20200403更新问题)

或者提示

 sudo vim /etc/docker/daemon.json(若没有自行创建)
写入:
{
  "registry-mirrors": [
    "http://hub-mirror.c.163.com"
  ],
  "insecure-registries": [
    "registry-1.docker.io"
  ]
}

最终重启一下docker:
sudo systemctl daemon-reload 
sudo systemctl restart docker

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值