树莓派安装docker

树莓派安装docker

概述

其实树莓派安装docker和平时安装docker没什么区别,但是我就是喜欢记录下,这次安装docker的原因就是因为为了方便使用,练习写dockerfile什么的

安装docker

首先官方的方式我是不推荐的,安装完docker之后因为中国的网络缘故我们还要修改docker的镜像仓库地址
废话不多说直接开始安装
首先打开这个地址
dev.aliyun.com
其实就是阿里云的docker镜像仓库地址
接着点击管理中心->镜像加速器,里面就有配置镜像仓库的方法,输入下面这句话安装docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

  ~ curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# Executing docker install script, commit: e749601
+ sh -c 'apt-get update -qq >/dev/null'
+ sh -c 'apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null'
+ sh -c 'curl -fsSL "https://mirrors.aliyun.com/docker-ce/linux/raspbian/gpg" | apt-key add -qq - >/dev/null'
+ sh -c 'echo "deb [arch=armhf] https://mirrors.aliyun.com/docker-ce/linux/raspbian jessie edge" > /etc/apt/sources.list.d/docker.list'
+ '[' raspbian = debian ']'
+ sh -c 'apt-get update -qq >/dev/null'
+ sh -c 'apt-get install -y -qq --no-install-recommends docker-ce >/dev/null'
+ sh -c 'docker version'
Client:
 Version:    18.03.0-ce
 API version:    1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built:    Wed Mar 21 23:27:19 2018
 OS/Arch:    linux/arm
 Experimental:    false
 Orchestrator:    swarm

Server:
 Engine:
  Version:    18.03.0-ce
  API version:    1.37 (minimum version 1.12)
  Go version:    go1.9.4
  Git commit:    0520e24
  Built:    Wed Mar 21 23:23:22 2018
  OS/Arch:    linux/arm
  Experimental:    false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

上面提示如果你不是使用root用户的,那么要把这个用户加入到docker组中,就是使用下面这个命令
sudo usermod -aG docker your-user

配置docker加速地址

只要执行下面的命令就好了

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["你的加速地址"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

如果你在pull镜像的时候出现下面的错误
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 127.0.0.1:53: server misbehaving

这个就是网络错误,我的是因为我的dns服务器没有设置好,在下面这个文件
vim /etc/resolv.conf
加上
nameserver 1.1.1.1
就好了

欢迎关注Bboysoul的博客www.bboysoul.com
Have Fun

上一篇:Linux 安装Redis


下一篇:docker安装