Raspberry Pi 4B-Install Docker
The installation tutorial on the Docker official website has explained that you can only install Docker on the Raspberry Pi using a script installation method, so the next introduction is to install Docker on the Raspberry Pi using a script
Docker installation
Obtain the installation script (community version)
curl -fsSL https://get.docker.com -o get-docker.sh
Execute the installation script
sudo sh get-docker.sh
After the installation is successful, as shown in the figure, sometimes the installation does not repeat several times
sudo sh get-docker.sh
Run Docker
Basic command
# Docker开机自启
sudo systemctl enable docker
# 启动Docker
sudo systemctl start docker
# 查看当前Docker版本
sudo docker version
# 重启Docker
sudo systemctl restart docker
Modify the mirror source
The Docker image source is used to download the image. By default, the download image of a foreign country will be slower, and it will be faster to switch to a domestic image.
Mirror image | connection |
---|---|
HKUST Mirror | https://docker.mirrors.ustc.edu.cn/ |
NetEase | https://hub-mirror.c.163.com/ |
#这里使用的是 科大镜像
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
EOF
#重新加载配置文件
sudo systemctl daemon-reload
#重新启动docker
sudo systemctl restart docker
Execute hello-world
sudo docker run hello-world
Seeing the following content indicates that Docker can be used normally
Uninstall
#卸载Docker Engine,CLI和Containerd软件包
sudo apt-get purge docker-ce docker-ce-cli containerd.io
#主机上的映像,容器,卷或自定义配置文件不会自动删除,要手动删除所有图像,容器和卷执行如下
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd