Ubuntu arm64 安装docker

通过docker官方链接安装,如果无法链接,需要通过vpn或者翻墙链接外网,国内如果屏蔽

1. 卸载旧版本

 Ubuntu 自带的 Docker 版本太低,需要先卸载旧的再安装新的。

sudo apt-get remove docker docker-engine docker.io containerd runc

2. 更新软件包列表和已安装软件的版本

sudo apt update

sudo apt upgrade

3. 安装必要的证书并允许 apt 包管理器使用以下命令通过 HTTPS 使用存储库

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

4. 添加 Docker 的官方 GPG 密钥

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

5. 添加 Docker 官方库(创建一个适合于当前 CPU 架构和系统版本的软件源)

sudo add-apt-repository \
   "deb [arch=arm64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

6. 使用命令更新 Ubuntu 源列表

sudo apt update

7. 安装最新 Docker CE:

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin

当然你也可以安装其他版本 Docker 。运行下列命令检查可以安装的 Docker 版本

apt-cache madison docker-ce

你可以挑选上面列表中的任何版本进行安装。

例如,安装 5:27.0.3-1~ubuntu.22.04~jammy 这个版本,运行:

sudo apt install docker-ce=5:27.0.3-1~ubuntu.22.04~jammy docker-ce-cli=5:27.0.3-1~ubuntu.22.04~jammy containerd.io

8. 查看状态

systemctl status docker
andy@andy-ubuntu:~/go/src/MQTT_Monitor$ systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-06-17 19:37:02 CST; 1h 37min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 883 (dockerd)
      Tasks: 9
     Memory: 104.4M
        CPU: 4.341s
     CGroup: /system.slice/docker.service
             └─883 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

6月 17 20:58:57 andy-ubuntu dockerd[883]: time="2024-06-17T20:58:57.689775222+08:00" level=info msg="Attemp>
6月 17 20:59:00 andy-ubuntu dockerd[883]: time="2024-06-17T20:59:00.447197605+08:00" level=warning msg="Err>
6月 17 20:59:00 andy-ubuntu dockerd[883]: time="2024-06-17T20:59:00.447464115+08:00" level=info msg="Attemp>
6月 17 20:59:10 andy-ubuntu dockerd[883]: time="2024-06-17T20:59:10.483309051+08:00" level=warning msg="Err>
6月 17 20:59:10 andy-ubuntu dockerd[883]: time="2024-06-17T20:59:10.483440555+08:00" level=info msg="Attemp>
6月 17 20:59:11 andy-ubuntu dockerd[883]: time="2024-06-17T20:59:11.129342292+08:00" level=info msg="Attemp>
6月 17 21:00:04 andy-ubuntu dockerd[883]: time="2024-06-17T21:00:04.899582554+08:00" level=info msg="Downlo>
6月 17 21:01:11 andy-ubuntu dockerd[883]: time="2024-06-17T21:01:11.956546678+08:00" level=info msg="Downlo>
6月 17 21:01:41 andy-ubuntu dockerd[883]: time="2024-06-17T21:01:41.365739627+08:00" level=error msg="Not c>
6月 17 21:01:55 andy-ubuntu dockerd[883]: time="2024-06-17T21:01:55.081241610+08:00" level=error msg="Not c>
lines 1-22/22 (END)

9.  如果没有启动,启动docker

sudo systemctl start docker

10. 使 Docker 服务在每次重启时自动启动:

sudo systemctl enable docker

11. 可以使用以下命令查看已安装的 Docker 版本

sudo docker version

12. 测试docker是否运行正常

sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

13. 如果不成功,更换镜像地址

修改/etc/docker/daemon.json ,如果没有先创建文件

{
"registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://dockerproxy.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://docker.nju.edu.cn",
    "http://mirrors.aliyun.com",
    "https://hxv6d2ac.mirror.aliyuncs.com"]
}
sudo systemctl daemon-reload

sudo systemctl restart docker

14.  可能的错误处理

    /Users/xxx/.docker/buildx/activity/desktop-linux: permission denied

chmod 755 /Users/xxx/.docker/buildx/activity/desktop-linux

安装完Docker之后,使用Docker命令,如Docker version命令,会提示
 ERROR: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": dial unix /var/run/docker.sock: connect: permission denied

 这种问题,通常是因为当前用户没有加入到Docker用户组所导致的。

sudo usermod -aG docker ${user}
sudo groupadd docker
sudo gpasswd -a ${user} docker
newgrp docker

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值