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

这篇具有很好参考价值的文章主要介绍了【docker错误解决系列】 ‘buildx‘ is not a docker command.。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题

[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.21
 API version:       1.41
 Go version:        go1.18.1
 Git commit:        20.10.21-0ubuntu1~18.04.3
 Built:             Thu Apr 27 05:50:21 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.1
  Git commit:       20.10.21-0ubuntu1~18.04.3
  Built:            Thu Apr 27 05:36:22 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.2
  GitCommit:        de8046a5501db9e0e478e1c10cbcfb21af4c6b2d
 runc:
  Version:          1.1.1
  GitCommit:        v1.1.0-20-g52de29d7
 docker-init:
  Version:          0.19.0
  GitCommit:        
[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.21
 API version:       1.41
 Go version:        go1.18.1
 Git commit:        20.10.21-0ubuntu1~18.04.3
 Built:             Thu Apr 27 05:50:21 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.1
  Git commit:       20.10.21-0ubuntu1~18.04.3
  Built:            Thu Apr 27 05:36:22 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.2
  GitCommit:        de8046a5501db9e0e478e1c10cbcfb21af4c6b2d
 runc:
  Version:          1.1.1
  GitCommit:        v1.1.0-20-g52de29d7
 docker-init:
  Version:          0.19.0
  GitCommit:        

尝试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.21
 API version:       1.41
 Go version:        go1.18.1
 Git commit:        20.10.21-0ubuntu1~18.04.3
 Built:             Thu Apr 27 05:50:21 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.1
  Git commit:       20.10.21-0ubuntu1~18.04.3
  Built:            Thu Apr 27 05:36:22 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.2
  GitCommit:        de8046a5501db9e0e478e1c10cbcfb21af4c6b2d
 runc:
  Version:          1.1.1
  GitCommit:        v1.1.0-20-g52de29d7
 docker-init:
  Version:          0.19.0
  GitCommit:   
[root@ningan .docker]# docker info |grep Experimental
WARNING: No swap limit support
 Experimental: 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 support
 Experimental: true
[root@ningan ~]# docker version
Client:
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.1
 Git commit:        20.10.21-0ubuntu1~18.04.3
 Built:             Thu Apr 27 05:50:21 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.1
  Git commit:       20.10.21-0ubuntu1~18.04.3
  Built:            Thu Apr 27 05:36:22 2023
  OS/Arch:          linux/amd64
  Experimental:     true                      ###########################  这个地方变成true了
 containerd:
  Version:          v1.6.2
  GitCommit:        de8046a5501db9e0e478e1c10cbcfb21af4c6b2d
 runc:
  Version:          1.1.1
  GitCommit:        v1.1.0-20-g52de29d7
 docker-init:
  Version:          0.19.0
  GitCommit:  
[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-135
  linux-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-144
  linux-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

文章来源地址https://www.toymoban.com/news/detail-833680.html

到了这里,关于【docker错误解决系列】 ‘buildx‘ is not a docker command.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • git: ‘lfs‘ is not a git command. See ‘git --help‘的解决方案

      大家好,我是爱编程的喵喵。双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中。从事机器学习以及相关的前后端开发工作。曾在阿里云、科大讯飞、CCF等比赛获得多次Top名次。现为CSDN博客专家、人工智能领域优质创作者。喜欢通过博客创作

    2024年02月11日
    浏览(49)
  • goland报错:“package command-line-arguments is not a main package”解决方案

    大家好!我是躺平哥。         今天模拟客户端和服务端交互时遇到了一个问题: “package command-line-arguments is not a main package”          翻译过来就是包命令行参数不是主包         因为在Go语言中,和java的main是有所区别的,具体区别如下:         在java中,任何

    2023年04月19日
    浏览(33)
  • 解决repo sync ( git )报错: git: ‘remote-https‘ is not a git command

    在Ubuntu 18.04上下载Android源码,遇到报错:git: ‘remote-https’ is not a git command。 使用apt命令升级git到最新版本,不能解决这个问题。 使用GitHub或者国内的git服务,用ssh方式的下载代码是可以的,HTTPS的方式会报同样的错误。 下载git源码,在本地编译: 看网上说需要有libcurl4-

    2024年02月09日
    浏览(51)
  • 出现 sudo: docker: command not found 的解决方法

    安装了docker,但是执行docker命令的时候,提示该问题:

    2024年02月12日
    浏览(37)
  • Docker中出现bash: vim: command not found解决方案

    RedHat系列:Redhat、Centos、Fedora等 Debian系列:Debian、Ubuntu等 RedHat系列的包管理工具是 yum Debian系列的包管理工具是 apt-get Debian系列 RedHat系列

    2024年02月07日
    浏览(42)
  • 如何解决docker中出现的“bash: vim: command not found”

    目录 问题描述: 问题解决: 在docker中,想要执行vim编辑文件,弹出“docker bash: vim: command not found“(如下图),请问该如何解决? 解决办法,主要分成两个步骤: 步骤1,执行如下命令: 步骤2,继续执行如下命令:  再执行vim命令,便不会报错。

    2024年02月13日
    浏览(40)
  • 前端date.locale is not a function错误解决办法

    在使用antd组件DatePicker时,修改数据之前做数据回显,但是在数据回显时总是会报一个错误:date.locale is not a function。经过一步步的排错,最终确定是使用antd中DatePicker(日期选择器)组件的问题,此时我只在表单中写了一个DatePicker组件,并在表单中进行了数据绑定 查阅了很

    2024年02月11日
    浏览(41)
  • docker 错误 WARNING: IPv4 forwarding is disabled. Networking will not work.

    这个错误出现在使用 docker 的服务器上,当你进入 docker 容器时,如果出现这样的 WARNING 提示,则表示服务器没有开启 IPv4 转发,按照本文的方法配置开启转发即可。 错误提示: WARNING: IPv4 forwarding is disabled. Networking will not work. 配置 IPv4 转发如下示例: 如果有的 docker 容器还是

    2024年02月05日
    浏览(48)
  • 出现 “‘mysql’ is not recognized as an internal or external command, operable program or batch file解决方法

    在 Windows 系统的 DOS 窗口通过命令行的方式登录 MySQL,出现 “‘mysql’ is not recognized as an internal or external command, operable program or batch file” 的提示 意味着系统无法识别或找不到 MySQL 的可执行文件 。这可能是由于以下几个原因导致的: MySQL 未正确安装:确保 MySQL 已正确安装并

    2024年02月07日
    浏览(50)
  • 如何解决 Python 错误 NameError: name ‘X‘ is not defined

    Python“ NameError: name is not defined ”发生在我们试图访问一个未定义的变量或函数时,或者在它被定义之前。 要解决该错误,需要确保我们没有拼错变量名并在声明后访问它。 下面是产生上述错误的示例代码。 问题是我们拼错了变量名。 请注意,变量、函数和类的名称区分大

    2024年02月01日
    浏览(72)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包