1、更新apt:命令 sudo apt-get update
2、安装linux-image-extra-* 包,这一步不可少,不然后面安装docker会从国外网址下载,一般被墙的下载不了, 也就安装不成功
命令:
sudo apt install linux-image-extra-$(uname -r) linux-image-extra-virtual
如果报错:
说明 linux-image-generic
应该已经安装了相关的linux-image-extra
包,但名称已更改为linux-modules-extra
。试试这个升级到最新的内核:
sudo apt update
sudo apt upgrade
sudo apt install --reinstall linux-image-generic
然后,重新启动并尝试使用以下命令:
sudo apt install linux-modules-extra-$(uname -r) linux-image-extra-virtual
3、安装https
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
如果您的Ubuntu里已经有了,这步省去
4、安装GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
5、验证 key的 fingerprint 为 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.
sudo apt-key fingerprint 0EBFCD88
6、安装仓库
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
7、再次更新
sudo apt-get update
8、安装docker-ce,这一步我没有用国内源,所以下载很慢
sudo apt-get install docker-ce
9、上面执行完毕,docker应该算是安装完毕了,可以输入下面命令测试是否成功
sudo docker run hello-world
输出一下内容说明安装成功:
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.
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://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/