赞
踩
在Ubuntu18.04上安装docker,依照这个指南:
安装指南
使用Install using the repository方法进行安装。
运行:
sudo apt-get install docker-ce docker-ce-cli containerd.io
报错如下:
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)
原因:由于/var/lib/dpkg/info/目录的某些问题带来的报错,可以先备份,再重新建一个空白的即可:
sudo mv /var/lib/dpkg/info/ /var/lib/dpkg/bak/ #备份info文件夹
sudo mkdir /var/lib/dpkg/info/ #重新建立info文件夹
再次安装docker目录:
sudo apt-get install docker-ce docker-ce-cli containerd.io
目录成功。
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是版本号,可替换
E: Version '18.06.3~ce~3-0~ubuntu' for 'docker-ce-cli' was not found
原因: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
安装成功:
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).
检查安装:
sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
原因:未启动docker服务
解决方法:
service docker start #启动服务
sudo docker run hello-world #测试安装,这步如果出现pull hello world镜像时timeout,需要挂代理或者用国内镜像。
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/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。