1.准备
uname -r
不管你是Ubuntu的哪个版本,Docker需要64的操作系统。此外你的kernel内核至少要在3.10版本之上。最近的3.10小版本或者最新的维护版本也是可以接受的。kernel3.10版本之前的系统缺少一些特性来运行docker容器。这些旧版本有些已知的bugs会导致数据丢失并且在一定条件下会频繁的故障。检查你当前的kernel版本,打开终端,输入
Docker的APT仓库包含1.7.1以及更高的版本。通过设置APT使用来自docker仓库的包。
1)登陆机器,用户必须使用sudo或者root权限。
2)打开终端
3)更新包信息,确保APT能使用https方式工作,并且CA证书已安装了
sudo apt-get update
报错:
原因是dns没有配置,解决办法?加入dns服务器地址,比如:
vi /etc/resolv.conf
nameserver 114.114.114.114
nameserver 8.8.8.8
2.Install packages to allow apt
to use a repository over HTTPS:
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
3.Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4.Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
, by searching for the last 8 characters of the fingerprint.
$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
5.Use the following command to set up the stable repository.
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
2.INSTALL DOCKER CE
1.Update the apt
package index.
$ sudo apt-get update
2.Install the latest version of Docker CE and containerd, or go to the next step to install a specific version:
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
3.To install a specific version of Docker CE, list the available versions in the repo, then select and install:
a. List the versions available in your repo:
$ apt-cache madison docker-ce
docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
...
b. Install a specific version using the version string from the second column, for example, 5:18.09.53-0ubuntu-xenial.
$ sudo apt-get install docker-ce=5:18.09.5~3-0~ubuntu-xenial docker-ce-cli=5:18.09.5~3-0~ubuntu-xenial containerd.io
4.Verify that Docker CE is installed correctly by running the hello-world
image.
$ sudo docker run hello-world