Docker
docker的使用
环境:
我是用的是Ubuntu 16.04.6 LTS的linux发行版
docker的官网: https://www.docker.com/
参考文档:https://docs.docker.com/get-docker/
1、安装
#首先卸载旧版本,如果没有可省略
sudo apt-get remove docker docker-engine docker.io containerd runc
#然后更新apt索引
$ sudo apt-get update
#安装依赖
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
#添加Docker的官方密钥
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#因为Docker是国外网站所以想要在国内流畅使用需要添加阿里云镜像密钥(建议)
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
#添加成功会提示ok!
#验证是否成功
$ sudo apt-key fingerprint 0EBFCD88
#添加仓官方仓库
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
#阿里云仓库如图
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AyApZZby-1605508091875)(C:\Users\X\AppData\Roaming\Typora\typora-user-images\image-20200524152311697.png)]
#正式安装docker
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
#运行helloworld
$ sudo docker run hello-word
#出现提示信息即为成功
#可以用命令查看docker版本和详细信息
$ sudo docker version
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b7f0
Built: Wed Mar 11 01:25:58 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b7f0
Built: Wed Mar 11 01:24:30 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683