安装docker
说明:本文使用.deb包安装docker
移除安装过得或者旧版本的docker(根据实际情况操作):
$ sudo apt-get remove docker docker-engine docker.io containerd runc
下载deb包:https://download.docker.com/linux/ubuntu/dists/
选择你系统的版本,我的是bionic,并点击进入pool/stable/
安装.deb,-i 后加.deb的路径
$ sudo dpkg -i /path/to/package.deb
验证是否安装成功:
$ 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'.
解决:https://blog.youkuaiyun.com/loovelj/article/details/91418524
参考:
官网:https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script
查看系统版本:https://blog.youkuaiyun.com/xiang_shao344/article/details/82806148
使用docker拉取镜像失败:
报错:docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled
或者Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout
解决:https://blog.youkuaiyun.com/BigData_Mining/article/details/87869147(推荐使用方法一)
注意:
1. 如果这里重启失败,报错Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
解决:重新编辑daemon.json,检查文件中是否有中文标点,如果文件中有文字标红,则一定有中文标点,将其修改为英文标点,重启docker即可
2. 如果进入文件夹/etc/docker/权限不够,报错:bash: cd: /etc/docker: 权限不够
解决:https://blog.youkuaiyun.com/u014717036/article/details/70338463