当前位置:   article > 正文

Ubuntu18.04安装Docker-报错:dpkg: error processing package docker-ce (--configure)

dpkg: error processing package docker-ce (--configure): installed docker-ce

Ubuntu18.04安装Docker

在Ubuntu18.04上安装docker,依照这个指南:
安装指南
使用Install using the repository方法进行安装。

报错dpkg: error processing package docker-ce (–configure)

运行:

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

报错如下:

dpkg: error processing package docker-ce (--configure):
 installed docker-ce package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of docker-ce-rootless-extras:
 docker-ce-rootless-extras depends on docker-ce; however:
  Package docker-ce is not configured yet.

dpkg: error processing package docker-ce-rootless-extras (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          Errors were encountered while processing:
 docker-ce
 docker-ce-rootless-extras
E: Sub-process /usr/bin/dpkg returned an error code (1)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

原因:由于/var/lib/dpkg/info/目录的某些问题带来的报错,可以先备份,再重新建一个空白的即可:

sudo mv /var/lib/dpkg/info/ /var/lib/dpkg/bak/  #备份info文件夹
sudo mkdir /var/lib/dpkg/info/      #重新建立info文件夹
  • 1
  • 2

再次安装docker目录:

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

目录成功。

安装docker引擎

sudo apt-get install docker-ce=18.06.3~ce~3-0~ubuntu docker-ce-cli=18.06.3~ce~3-0~ubuntu containerd.io   # 18.06.3~ce~3-0~ubuntu是版本号,可替换
  • 1

报错:E: Version ‘18.06.3ce3-0~ubuntu’ for ‘docker-ce-cli’ was not found

E: Version '18.06.3~ce~3-0~ubuntu' for 'docker-ce-cli' was not found
  • 1

原因:docker-ce-cli包在docker ce 18.09后引入,所以上面选择的18.06.3版本低于此版本。
解决方法:选择高于18.09版本的docker引擎安装:

sudo apt-get install docker-ce=5:20.10.1~3-0~ubuntu-bionic docker-ce-cli=5:20.10.1~3-0~ubuntu-bionic containerd.io
  • 1

安装成功:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
containerd.io is already the newest version (1.4.3-1).
docker-ce-cli is already the newest version (5:20.10.1~3-0~ubuntu-bionic).
docker-ce is already the newest version (5:20.10.1~3-0~ubuntu-bionic).
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

检查安装:

sudo docker run hello-world
  • 1

报错:docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock.

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
  • 1
  • 2

原因:未启动docker服务
解决方法:

service docker start   #启动服务
sudo docker run hello-world    #测试安装,这步如果出现pull hello world镜像时timeout,需要挂代理或者用国内镜像。
  • 1
  • 2

Docker安装成功:

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

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

参考

- [1] [程序园](http://www.voidcn.com/article/p-cubosaxw-bxv.html) -
- [2] [博客](https://blog.csdn.net/wireless911/article/details/88989620)
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/88781
推荐阅读
相关标签
  

闽ICP备14008679号