buildx is not a docker command on linux/amd64 ?

Created on 14 Aug 2019  Â·  25Comments  Â·  Source: docker/buildx

Hi,
I have docker 19.03 on ubuntu amd64 and I tried the steps in your readme but fail to get buildx command working. It complains command not found. What do I need to get it working? I tried beta release as well and same issue. I am looking to compile images for arm64.

Appreciate the help a lot,
Puja
$ cat ~/.docker/config.json
{
"experimental": "enabled"
}
$ ls -l ~/.docker/cli-plugins/docker-buildx
total 55936
drwxr-xr-x 2 pujag newhiredefaultgrp 4096 Aug 12 14:05 .
drwxr-xr-x 3 pujag newhiredefaultgrp 4096 Aug 12 14:01 ..
-rwxr-xr-x 1 pujag newhiredefaultgrp 57036919 Aug 12 14:04 buildx-v0.2.0.linux-amd64
$ docker version
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:21:05 2019
OS/Arch: linux/amd64
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.12)
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:19:41 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683

Most helpful comment

docker-buildx doesn't need to be on $PATH but ~/.docker/cli-plugins/docker-buildx is the binary itself, not a directory containing the binary.

If you don't use Docker Desktop you need to set up qemu support in your kernel yourself and buildx will pick it up on bootstrap. You can use https://github.com/multiarch/qemu-user-static#getting-started or https://hub.docker.com/r/docker/binfmt/tags images to install the emulation support.

All 25 comments

I've had happen before since ~/.docker/cli-plugins/docker-buildx is mot in $PATH
you can manually run that to install it.
Or straight away refer to it for execution (that's what I personally do)
If you find the right steps to enable it as drop in, a PR to update the docs would be appreciated

BTW, that's the old release, consider upgrading to 0.3 which has nice additions.
I believe that the nightly builder have been broken since last docker release, so no new version has been pushed

Thank you so much for the reply. Works for me now. Path issues. Yes will update, I see newer version now.

How can I compile images for arm64 embedded on my amd64 linux machine? Buildx lists only linux/amd64 in platforms for me. I had downloaded buildx-3.0-amd64 and saved it as docker-buildx in cli-plugins. is that the right way to do it?

$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
mybuilder * docker-container
mybuilder0 unix:///var/run/docker.sock running linux/amd64, linux/386
default docker
default default running linux/amd64

docker-buildx doesn't need to be on $PATH but ~/.docker/cli-plugins/docker-buildx is the binary itself, not a directory containing the binary.

If you don't use Docker Desktop you need to set up qemu support in your kernel yourself and buildx will pick it up on bootstrap. You can use https://github.com/multiarch/qemu-user-static#getting-started or https://hub.docker.com/r/docker/binfmt/tags images to install the emulation support.

Thanks @tonistiigi . Yes I had created a directory instead of file, works perfect now.

Thanks for the link, so if I understand it right qemu-user-static seems to be useful if I wanted to run arm64 image on host x86, but if I just wanted to create arm64 image on host x86 and run on embedded arm64 I might not need qemu-user-static?

@gupta05 If your Dockerfile needs to execute RUN commands for another architecture you need to load the qemu-user-static support to kernel before. If you only use other commands you can build directly for any platform.

Docker-ce CLI 19.03.2 , git commit 6a30dfca03 , experimental enabled . docker buildx yields 'buildx' is not a docker command. Does this suggest that buildx is not bundled for docker-ce CLI 19.03 (that the README.md is wrong) ?

@yxliang01 do you have the plugin installed?

@FernandoMiguel I didn't install myself because in the README.md of this repo, it says buildx is bundled with docker 19.03, right? So, I wouldn't expect the need to install it manually. See https://github.com/docker/buildx/blob/master/README.md#docker-ce .

@yxliang01 I always found I had to either install it or include it in the $PATH

@FernandoMiguel I didn't install myself because in the README.md of this repo, it says buildx is bundled with docker 19.03, right? So, I wouldn't expect the need to install it manually. See https://github.com/docker/buildx/blob/master/README.md#docker-ce .

Did you add "experimental": "enabled" in your ~/.docker/config.json?

@darkvertex No, but I do DOCKER_CLI_EXPERIMENTAL=1 and also did docker info to confirm that the experimental mode is enabled.

$ export DOCKER_CLI_EXPERIMENTAL=enabled
$ docker version
Client:
 Version:           19.03.5-ce
 API version:       1.40
 Go version:        go1.13.4
 Git commit:        633a0ea838
 Built:             Fri Nov 15 03:19:09 2019
 OS/Arch:           linux/amd64
 Experimental:      true

Server:
 Engine:
  Version:          19.03.4-ce
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.1
  Git commit:       9013bf583a
  Built:            Sat Oct 19 04:39:38 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.3.0.m
  GitCommit:        d50db0a42053864a270f648048f9a8b4f24eced3.m
 runc:
  Version:          1.0.0-rc9
  GitCommit:        d736ef14f0288d6993a1845745d6756cfc9ddd5a
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
$ docker buildx bake
docker: 'buildx' is not a docker command.
See 'docker --help'

Did you add "experimental": "enabled" in your ~/.docker/config.json?

Did not change anything for me.

I am facing the same issue. Have tried with both editing the config.json file and exporting the environment variable, but still facing this issue.

Any help would be appreciated. Thanks.

I am facing the same issue. Have tried with both editing the config.json file and exporting the environment variable, but still facing this issue.

Any help would be appreciated. Thanks.

Same here. What worked for me on Debian buster was to create the file /etc/docker/daemon.json and then add the following to it:

{
    "experimental": true
}

I then restarted the docker daemon by running sudo service docker restart and it seems to have enabled experimental mode:

$ docker info | grep -i exp
WARNING: No swap limit support  
 Experimental: true

oh, ok, I see my confusion here, I was not paying much attention to the comments and was just enabling experimental in the file /etc/docker/daemon.json but not for the docker-cli, which is in another location ~/.docker/config.json (or using the env var DOCKER_CLI_EXPERIMENTAL=enabled)
After setting the docker CLI (as well as the daemon) as experimental, I managed to make it work as well =)

Does this work for you as well? (means you don't have to mess with config files):

DOCKER_BUILD_KIT=1 DOCKER_CLI_EXPERIMENTAL=enabled docker buildx --help

I'm experiencing the same problem. As you can see, both client and server have experimental enabled, and this is on Docker 19.03 which should have buildx included. I'd appreciate any advice.

# docker version
Client:
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.13.8
 Git commit:        afacb8b7f0
 Built:             Wed Mar 11 23:42:35 2020
 OS/Arch:           linux/amd64
 Experimental:      true

Server:
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.8
  Git commit:       afacb8b7f0
  Built:            Wed Mar 11 22:48:33 2020
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.3.3-0ubuntu2
  GitCommit:        
 runc:
  Version:          spec: 1.0.1-dev
  GitCommit:        
 docker-init:
  Version:          0.18.0
  GitCommit:        
# docker buildx
docker: 'buildx' is not a docker command.
See 'docker --help'

@cjyar Try following steps:

1. wget https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
2. chmod a+x buildx-v0.4.1.linux-amd64
3. mkdir -p ~/.docker/cli-plugins
4. mv buildx-v0.4.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx

Now the command docker buildx version should show you the buildx version installed.

Thanks @shahidhs-ibm; that worked. Did I misunderstand the documentation? I thought it was supposed to work with Docker 19.03 if I just enabled experimental mode.

Same issue for me – I think the docs are just wrong here

Docker Buildx is already included in Docker 19.03 and you don't need to download and copy the binary, you just need to enable experimental features in Docker CLI or Docker Desktop:

To enable experimental features in the Docker CLI, edit the config.json file and set experimental to enabled.

To enable experimental features from the Docker Desktop menu, click Settings (Preferences on macOS) > Command Line and then turn on the Enable experimental features toggle. Click Apply & Restart.

@antoniodvr But AFAICT the issue is it seems like you do need to do so for some repackaged versions supplied with distros – as noted in my PR. It came up for me and @cjyar at least

@cjyar Try following steps:

1. wget https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
2. chmod a+x buildx-v0.4.1.linux-amd64
3. mkdir -p ~/.docker/cli-plugins
4. mv buildx-v0.4.1.linux-amd64 ~/.docker/cli-plugins/docker-buildx

Now the command docker buildx version should show you the buildx version installed.

Thanks a lot, with this I managed to get docker buildx to run (using Fedora 32).

Out of curiosity, does buildx update automatically? I substituted 4.1 with 4.2 in your commands, but is there a way to avoid redoing it when the next version releases?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blabla1337 picture blabla1337  Â·  10Comments

ep4sh picture ep4sh  Â·  5Comments

Aaltis picture Aaltis  Â·  6Comments

patrickelectric picture patrickelectric  Â·  7Comments

dpipemazo picture dpipemazo  Â·  10Comments