docker安装

docker安装

1.安装Docker Engine和containerd

$ apt-get update		# 更新apt包索引

$ apt-get install  apt-transport-https  ca-certificates  curl  gnupg  lsb-release		 # 安装软件以允许apt通过 HTTPS 使用存储库

$  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg		# 添加Docker官方的GPG密钥

$ echo   "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null		# 设置稳定存储库

$ apt-get update		# 更新apt包索引

$ apt-get install docker-ce docker-ce-cli containerd.io		# 安装最新版本的Docker Engine和containerd

2.配置docker镜像加速器:

国内加速器服务,例如:

科大镜像:https://docker.mirrors.ustc.edu.cn/
网易:https://hub-mirror.c.163.com/
阿里云:https://<你的ID>.mirror.aliyuncs.com
七牛云加速器:https://reg-mirror.qiniu.com

Docker版本大于 1.10.0,可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

$ sudo mkdir -p /etc/docker
$ sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://<你的ID>.mirror.aliyuncs.com"]
}
EOF
$ sudo systemctl daemon-reload

$ sudo systemctl restart docker

3.安装docker-compose

$ sudo add-apt-repository universe		# 先添加universe 源仓库,准备安装python2和pip2

$ sudo apt update 		# 更新软件包索引

$ sudo apt install python		# 安装 Python 2

$ wget https://bootstrap.pypa.io/pip/2.7/get-pip.py		# 下载get-pip.py脚本

$ python2 get-pip.py		# 使用 python2运行脚本来为 Python 2 安装 pip

$ pip install docker-compose		# 安装docker-compose

遇到“ERROR: Package 'pyrsistent' requires a different Python: 2.7.17 not in '>3.5”的情况时,安装指定版本的pyrsistent

$ pip install pyrsistent==0.15.7		# 支持python2.7的最新版本

相关文章

Docker是什么Docker是 Docker.Inc 公司开源的一个基于 LXC技...
本文为原创,原始地址为:http://www.cnblogs.com/fengzheng...
镜像操作列出镜像:$ sudo docker imagesREPOSITORY TAG IMA...
本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p...
在 Docker 中,如果你修改了一个容器的内容并希望将这些更改...
在Docker中,--privileged 参数给予容器内的进程几乎相同的权...