问题
[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
文章来源:https://www.toymoban.com/news/detail-833680.html
到了这里,关于【docker错误解决系列】 ‘buildx‘ is not a docker command.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!