最近了解了一些有关docker的知识,正好手边有个树莓派,就决定在树莓派上安装下docker玩一玩.
有两种安装方法
本教程只针对于Debian/Ubuntu发行版
1.相对麻烦的安装,但是最稳妥
1.如果之前安装过docker,先卸载
sudo sudo apt-get remove docker docker-engine docker.io
2.安装依赖
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
3.安装信任docker的GPG公钥
# debian发行版
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
# ubuntu发行版
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4.添加软件仓库
# amd64架构
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
# arm架构
echo "deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
5.安装
sudo apt-get update
sudo apt-get install docker-ce
2.脚本一键安装
sudo apt-get update
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
但是官方脚本太慢
# 使用阿里云脚本安装
curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -
检验是否安装成功
输入
sudo docker run hello-world
如果出现下图中的提示即安装成功
docker镜像加速
国内网络拉取官方镜像相当慢,这就需要使用国内的镜像网站来加速了
新建这个json文件
sudo nano /etc/docker/daemon.json
之后写入
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
保存退出