【docker错误解决系列】 ‘buildx‘ is not a docker command.

news/2024/11/2 8:31:47/

文章目录

  • 问题
  • 环境
  • 解决办法
    • 尝试1:修改~/.docker /config.json
    • 尝试2:exporter DOCKER_CLI_EXPERIMENTAL=enabled
    • 尝试3:修改/etc/docker/daemon.json --> Experimental成功开启
    • 尝试4:开启binfmt
    • 尝试5:安装docker-buildx-plugin --> docker buildx 成功

问题

[root@ningan ~]# docker buildx
docker: 'buildx' is not a docker command.
See 'docker --help'

环境

[root@ningan ~]# uname -a
Linux ningan 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[root@ningan ~]# docker version
Client:Version:           20.10.21API version:       1.41Go version:        go1.18.1Git commit:        20.10.21-0ubuntu1~18.04.3Built:             Thu Apr 27 05:50:21 2023OS/Arch:           linux/amd64Context:           defaultExperimental:      trueServer:Engine:Version:          20.10.21API version:      1.41 (minimum version 1.12)Go version:       go1.18.1Git commit:       20.10.21-0ubuntu1~18.04.3Built:            Thu Apr 27 05:36:22 2023OS/Arch:          linux/amd64Experimental:     falsecontainerd:Version:          v1.6.2GitCommit:        de8046a5501db9e0e478e1c10cbcfb21af4c6b2drunc:Version:          1.1.1GitCommit:        v1.1.0-20-g52de29d7docker-init:Version:          0.19.0GitCommit:        
[root@ningan ~]# 

解决办法

尝试1:修改~/.docker /config.json

[root@ningan ~]# mkdir ~/.docker 
mkdir: cannot create directory ‘/root/.docker’: File exists
[root@ningan ~]# cd .docker/
[root@ningan .docker]# ll
total 24
drwx------  3 root root  4096 Jan 23 14:20 ./
drwx------ 68 root root  4096 Feb 20 10:53 ../
-rw-------  1 root root   447 Jan 23 14:20 config.json
drwxr-xr-x 85 root root 12288 Jan 23 14:55 manifests/[root@ningan ~]# vi config.json
{..."experimental": "enabled"
}
[root@ningan .docker]# docker buildx version
docker: 'buildx' is not a docker command.
See 'docker --help'
[root@ningan .docker]# docker version
Client:Version:           20.10.21API version:       1.41Go version:        go1.18.1Git commit:        20.10.21-0ubuntu1~18.04.3Built:             Thu Apr 27 05:50:21 2023OS/Arch:           linux/amd64Context:           defaultExperimental:      trueServer:Engine:Version:          20.10.21API version:      1.41 (minimum version 1.12)Go version:       go1.18.1Git commit:       20.10.21-0ubuntu1~18.04.3Built:            Thu Apr 27 05:36:22 2023OS/Arch:          linux/amd64Experimental:     falsecontainerd:Version:          v1.6.2GitCommit:        de8046a5501db9e0e478e1c10cbcfb21af4c6b2drunc:Version:          1.1.1GitCommit:        v1.1.0-20-g52de29d7docker-init:Version:          0.19.0GitCommit:        

尝试2:exporter DOCKER_CLI_EXPERIMENTAL=enabled

[root@ningan .docker]# export DOCKER_CLI_EXPERIMENTAL=enabled
[root@ningan .docker]# 
[root@ningan .docker]# docker buildx version
docker: 'buildx' is not a docker command.
See 'docker --help'
[root@ningan .docker]# docker version
Client:Version:           20.10.21API version:       1.41Go version:        go1.18.1Git commit:        20.10.21-0ubuntu1~18.04.3Built:             Thu Apr 27 05:50:21 2023OS/Arch:           linux/amd64Context:           defaultExperimental:      trueServer:Engine:Version:          20.10.21API version:      1.41 (minimum version 1.12)Go version:       go1.18.1Git commit:       20.10.21-0ubuntu1~18.04.3Built:            Thu Apr 27 05:36:22 2023OS/Arch:          linux/amd64Experimental:     falsecontainerd:Version:          v1.6.2GitCommit:        de8046a5501db9e0e478e1c10cbcfb21af4c6b2drunc:Version:          1.1.1GitCommit:        v1.1.0-20-g52de29d7docker-init:Version:          0.19.0GitCommit:   
[root@ningan .docker]# docker info |grep Experimental
WARNING: No swap limit supportExperimental: false     

尝试3:修改/etc/docker/daemon.json --> Experimental成功开启

[root@ningan .docker]# vi /etc/docker/daemon.json
{"experimental": true,...
}
[root@ningan .docker]# systemctl restart docker
[root@ningan .docker]# docker info |grep Experimental
WARNING: No swap limit supportExperimental: true
[root@ningan ~]# docker version
Client:Version:           20.10.21API version:       1.41Go version:        go1.18.1Git commit:        20.10.21-0ubuntu1~18.04.3Built:             Thu Apr 27 05:50:21 2023OS/Arch:           linux/amd64Context:           defaultExperimental:      trueServer:Engine:Version:          20.10.21API version:      1.41 (minimum version 1.12)Go version:       go1.18.1Git commit:       20.10.21-0ubuntu1~18.04.3Built:            Thu Apr 27 05:36:22 2023OS/Arch:          linux/amd64Experimental:     true                      ###########################  这个地方变成true了containerd:Version:          v1.6.2GitCommit:        de8046a5501db9e0e478e1c10cbcfb21af4c6b2drunc:Version:          1.1.1GitCommit:        v1.1.0-20-g52de29d7docker-init:Version:          0.19.0GitCommit:  
[root@ningan ~]# docker buildx version
docker: 'buildx' is not a docker command.
See 'docker --help      

尝试4:开启binfmt

[root@ningan ~]# docker run --rm --privileged tonistiigi/binfmt:latest --install all
Unable to find image 'tonistiigi/binfmt:latest' locally
latest: Pulling from tonistiigi/binfmt
8d4d64c318a5: Pull complete 
e9c608ddc3cb: Pull complete 
Digest: sha256:66e11bea77a5ea9d6f0fe79b57cd2b189b5d15b93a2bdb925be22949232e4e55
Status: Downloaded newer image for tonistiigi/binfmt:latest
installing: riscv64 OK
installing: mips64le OK
installing: ppc64le OK
installing: mips64 OK
installing: arm64 OK
installing: arm OK
installing: s390x OK
{"supported": ["linux/amd64","linux/arm64","linux/riscv64","linux/ppc64le","linux/s390x","linux/386","linux/mips64le","linux/mips64","linux/arm/v7","linux/arm/v6"],"emulators": ["jar","llvm-6.0-runtime.binfmt","python2.7","python3.6","qemu-aarch64","qemu-arm","qemu-mips64","qemu-mips64el","qemu-ppc64le","qemu-riscv64","qemu-s390x"]
}
[root@ningan ~]# 
[root@ningan ~]# ls -l /proc/sys/fs/binfmt_misc/
total 0
-rw-r--r-- 1 root root 0 Feb  4 21:40 jar
-rw-r--r-- 1 root root 0 Feb  4 21:40 llvm-6.0-runtime.binfmt
-rw-r--r-- 1 root root 0 Feb  4 21:40 python2.7
-rw-r--r-- 1 root root 0 Feb  4 21:40 python3.6
-rw-r--r-- 1 root root 0 Feb 20 11:29 qemu-aarch64
-rw-r--r-- 1 root root 0 Feb 20 11:29 qemu-arm
-rw-r--r-- 1 root root 0 Feb 20 11:29 qemu-mips64
-rw-r--r-- 1 root root 0 Feb 20 11:29 qemu-mips64el
-rw-r--r-- 1 root root 0 Feb 20 11:29 qemu-ppc64le
-rw-r--r-- 1 root root 0 Feb 20 11:29 qemu-riscv64
-rw-r--r-- 1 root root 0 Feb 20 11:29 qemu-s390x
--w------- 1 root root 0 Feb  4 21:40 register
-rw-r--r-- 1 root root 0 Feb  4 21:40 status
[root@ningan ~]# 
[root@ningan ~]# grep -r "enabled" /proc/sys/fs/binfmt_misc/ 
/proc/sys/fs/binfmt_misc/qemu-s390x:enabled
/proc/sys/fs/binfmt_misc/qemu-arm:enabled
/proc/sys/fs/binfmt_misc/qemu-aarch64:enabled
/proc/sys/fs/binfmt_misc/qemu-mips64:enabled
/proc/sys/fs/binfmt_misc/qemu-ppc64le:enabled
/proc/sys/fs/binfmt_misc/qemu-mips64el:enabled
/proc/sys/fs/binfmt_misc/qemu-riscv64:enabled
/proc/sys/fs/binfmt_misc/jar:enabled
/proc/sys/fs/binfmt_misc/python2.7:enabled
/proc/sys/fs/binfmt_misc/llvm-6.0-runtime.binfmt:enabled
/proc/sys/fs/binfmt_misc/python3.6:enabled
grep: /proc/sys/fs/binfmt_misc/register: Invalid argument
/proc/sys/fs/binfmt_misc/status:enabled
[root@ningan ~]# docker buildx
docker: 'buildx' is not a docker command.
See 'docker --help'
[root@ningan ~]# 

尝试5:安装docker-buildx-plugin --> docker buildx 成功

[root@ningan ~]# sudo apt install docker-buildx-plugin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package docker-buildx-plugin
[root@ningan ~]# apt update
Hit:1 https://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 https://mirrors.aliyun.com/ubuntu bionic-security InRelease             
Hit:3 https://mirrors.aliyun.com/ubuntu bionic-updates InRelease              
Hit:4 https://mirrors.aliyun.com/ubuntu bionic-backports InRelease              
Reading package lists... Done                                                   
Building dependency tree       
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.# 添加 Docker 官方 GPG 密钥:
[root@ningan ~]# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
# 添加 Docker 官方仓库:
[root@ningan ~]# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Hit:1 https://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 https://mirrors.aliyun.com/ubuntu bionic-security InRelease              
Hit:3 https://mirrors.aliyun.com/ubuntu bionic-updates InRelease                
Hit:4 https://mirrors.aliyun.com/ubuntu bionic-backports InRelease              
Get:5 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:6 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [39.0 kB]
Fetched 103 kB in 4s (24.2 kB/s)    
Reading package lists... Done# 更新软件源列表并安装 `docker-buildx-plugin`
[root@ningan ~]# sudo apt update  
Hit:1 https://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 https://mirrors.aliyun.com/ubuntu bionic-security InRelease                                                               
Hit:3 https://mirrors.aliyun.com/ubuntu bionic-updates InRelease                                                                 
Hit:4 https://download.docker.com/linux/ubuntu bionic InRelease                                                                  
Hit:5 https://mirrors.aliyun.com/ubuntu bionic-backports InRelease        
Reading package lists... Done                      
Building dependency tree       
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.
[root@ningan ~]# sudo apt install docker-buildx-plugin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:linux-hwe-5.4-headers-5.4.0-126 linux-hwe-5.4-headers-5.4.0-131 linux-hwe-5.4-headers-5.4.0-132 linux-hwe-5.4-headers-5.4.0-135linux-hwe-5.4-headers-5.4.0-136 linux-hwe-5.4-headers-5.4.0-137 linux-hwe-5.4-headers-5.4.0-139 linux-hwe-5.4-headers-5.4.0-144linux-hwe-5.4-headers-5.4.0-146 linux-hwe-5.4-headers-5.4.0-147 linux-hwe-5.4-headers-5.4.0-148 pkg-php-tools shtool
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:docker-buildx-plugin
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 26.1 MB of archives.
After this operation, 71.2 MB of additional disk space will be used.
Get:1 https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-buildx-plugin amd64 0.10.5-1~ubuntu.18.04~bionic [26.1 MB]
Fetched 26.1 MB in 7s (3,669 kB/s)                                                                                                    
Selecting previously unselected package docker-buildx-plugin.
(Reading database ... 382316 files and directories currently installed.)
Preparing to unpack .../docker-buildx-plugin_0.10.5-1~ubuntu.18.04~bionic_amd64.deb ...
Unpacking docker-buildx-plugin (0.10.5-1~ubuntu.18.04~bionic) ...
Setting up docker-buildx-plugin (0.10.5-1~ubuntu.18.04~bionic) ...
[root@ningan ~]# docker buildx version
github.com/docker/buildx v0.10.5 86bdced

http://www.ppmy.cn/news/1361280.html

相关文章

Vue | (四)使用Vue脚手架(上) | 尚硅谷Vue2.0+Vue3.0全套教程

文章目录 📚初始化脚手架🐇创建初体验🐇分析脚手架结构🐇关于render🐇查看默认配置 📚ref与props🐇ref属性🐇props配置项 📚混入📚插件📚scoped样…

Bert基础(二)--多头注意力

多头注意力 顾名思义,多头注意力是指我们可以使用多个注意力头,而不是只用一个。也就是说,我们可以应用在上篇中学习的计算注意力矩阵Z的方法,来求得多个注意力矩阵。让我们通过一个例子来理解多头注意力层的作用。以All is well…

LeetCode 1798. 你能构造出连续值的最大数目

1.题目 给你一个长度为 n 的整数数组 coins ,它代表你拥有的 n 个硬币。第 i 个硬币的值为 coins[i] 。如果你从这些硬币中选出一部分硬币,它们的和为 x ,那么称,你可以 构造 出 x 。 请返回从 0 开始(包括 0 &#xf…

C++奇怪的 ::template

答疑解惑 怎么会有::template的写法 起初 在阅读stl的源码的时候&#xff0c;发现了一条诡异的代码 // ALIAS TEMPLATE _Rebind_alloc_t template<class _Alloc,class _Value_type> using _Rebind_alloc_t typename allocator_traits<_Alloc>::template rebind…

杰发科技AC7801——SRAM 错误检测纠正

0.概述 7801暂时无错误注入&#xff0c;无法直接进中断看错误情况&#xff0c;具体效果后续看7840的带错误注入的测试情况。 1.简介 2.特性 3.功能 4.调试 可以看到在库文件里面有ecc_sram的库。 在官方GPIO代码里面写了点测试代码 成功打开2bit中断 因为没有错误注入&#x…

鼠标右键助手专业版 MouseBoost PRO for Mac v3.3.6中文破解

MouseBoost Pro mac版是一款简单实用的鼠标右键助手专业版&#xff0c;MouseBoost Pro for Mac只要轻点你的鼠标右键&#xff0c;就可以激活你想要的各种功能&#xff0c;让你的工作效率大幅度提高&#xff0c;非常好用。 软件下载&#xff1a;MouseBoost PRO for Mac v3.3.6中…

第十二天-ppt的操作

目录 创建ppt文档 安装 使用 段落的使用 段落添加数据 段落中定义多个段落 自定义段落 ppt插入表表格 PPT插入图片 读取ppt 读取ppt整体对象 ​编辑 获取ppt文本 获取表格内容 创建ppt文档 安装 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple python…

SpringBoot3整合elasticsearch8

版本 SpringBoot 3.0 Elasticsearch 8.12.1 依赖 我使用的 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency> 还可以用&#xff0c;但我没用…