直接上手开干!
前言
此文档查看官网的doc文档:Install Docker Engine on Ubuntu | Docker Documentation
步骤
1. 卸载旧的版本
旧版本的Docker过去的名字 docker
, docker.io
, 或 docker-engine
. 卸载任何这类较早版本之前,企图安装 一个新的版本:
sudo apt-get remove docker docker-engine docker.io containerd runc
2.安装相应的apt依赖
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
注意:若上述失败请依次安装
sudo apt-get install apt-transport-https
sudo apt-get install ca-certificates
sudo apt-get install curl
sudo apt-get install gnupg-agent
sudo apt-get install software-properties-common
3.配置阿里云的gpg
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4.配置阿里云的docker镜像,设置一个稳定的仓库
注意:如果不知道执行命令查看::vi /etc/apt/sources.list 最开始的地方会有“ Release amd64 ”字样,我的是这个!!!
x86_64/amd64:
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
armhf:
sudo add-apt-repository "deb [arch=armhf] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
arm64:
sudo add-apt-repository "deb [arch=arm64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable”
5.再更新一次 apt
sudo apt-get update
6.安装最新的 docker
sudo apt-get install docker-ce docker-ce-cli containerd.io
7.运行hello-world
sudo docker run hello-world
出现以下为启动正常!!!
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:94ebc7edf3401f299cd3376a1669bc0a49aef92d6d2669005f9bc5ef028dc333
Status: Downloaded newer image for hello-world:latest
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/