Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildx is not a docker command on linux/amd64 ? #132

Closed
pujag-xlnx opened this issue Aug 13, 2019 · 34 comments · Fixed by #649
Closed

buildx is not a docker command on linux/amd64 ? #132

pujag-xlnx opened this issue Aug 13, 2019 · 34 comments · Fixed by #649

Comments

@pujag-xlnx
Copy link

pujag-xlnx commented Aug 13, 2019

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

@FernandoMiguel
Copy link
Contributor

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

@FernandoMiguel
Copy link
Contributor

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

@pujag-xlnx
Copy link
Author

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

@pujag-xlnx
Copy link
Author

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

@tonistiigi
Copy link
Member

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.

@pujag-xlnx
Copy link
Author

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?

@tonistiigi
Copy link
Member

@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.

@yxliang01
Copy link

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) ?

@FernandoMiguel
Copy link
Contributor

@yxliang01 do you have the plugin installed?

@yxliang01
Copy link

yxliang01 commented Sep 15, 2019

@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 .

@FernandoMiguel
Copy link
Contributor

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

@darkvertex
Copy link

@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?

@yxliang01
Copy link

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

@teohhanhui
Copy link

$ 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.

@madhavbhv06
Copy link

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.

@NullHypothesis
Copy link

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

@arruda
Copy link

arruda commented Feb 6, 2020

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 =)

@adriantorrie
Copy link

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

pschmitt added a commit to pschmitt/zabbix-docker-multiarch that referenced this issue Mar 5, 2020
@cjyar
Copy link

cjyar commented May 24, 2020

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'

@shahidhs-ibm
Copy link

@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.

@cjyar
Copy link

cjyar commented May 30, 2020

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.

@admackin
Copy link
Contributor

admackin commented Sep 8, 2020

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

@antoniodvr
Copy link

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.

@admackin
Copy link
Contributor

@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

@What-is-water93
Copy link

@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?

@hazmeister
Copy link

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?

If you have jq:

LATEST=$(wget -qO- "https://api.github.com/repos/docker/buildx/releases/latest" | jq -r .name)
wget https://github.com/docker/buildx/releases/download/$LATEST/buildx-$LATEST.linux-amd64
chmod a+x buildx-$LATEST.linux-amd64
mkdir -p ~/.docker/cli-plugins
mv buildx-$LATEST.linux-amd64 ~/.docker/cli-plugins/docker-buildx

@vojkny
Copy link

vojkny commented Sep 29, 2021

DOCKER_BUILD_KIT=1 DOCKER_CLI_EXPERIMENTAL=enabled docker buildx --help

I have

docker --version
Docker version 19.03.14, build 5eb3275

but when I run what you suggested, I am getting:

# DOCKER_BUILD_KIT=1 DOCKER_CLI_EXPERIMENTAL=enabled docker buildx
docker: 'buildx' is not a docker command.
See 'docker --help'

@materemias
Copy link

DOCKER_BUILD_KIT=1 DOCKER_CLI_EXPERIMENTAL=enabled docker buildx --help

I have

docker --version
Docker version 19.03.14, build 5eb3275

but when I run what you suggested, I am getting:

# DOCKER_BUILD_KIT=1 DOCKER_CLI_EXPERIMENTAL=enabled docker buildx
docker: 'buildx' is not a docker command.
See 'docker --help'

buildx is a cli plugin and needs to be installed first

@abdennour
Copy link

Using the container image abdennour/docker:20.10.9-buildx

# install
alias docker='docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock:ro abdennour/docker:20.10.9-buildx'
# run 
docker buildx version
docker buildx du

# clean & return back to the main docker command
unalias docker

@AndnixSH
Copy link

AndnixSH commented Nov 8, 2021

i'm getting this issue when using sudo docker buildx but i need sudo permission for my image

@djmaze
Copy link

djmaze commented Nov 8, 2021

@AndnixSH Try sudo -E.

@Goldenflamer
Copy link

Goldenflamer commented Jan 30, 2022

abdennour/docker

Any chance you could provide this image as arm64 please :) ? @abdennour

@crazy-max
Copy link
Member

@Goldenflamer You can use this one if you want: https://github.com/crazy-max/docker-docker#about

@Goldenflamer
Copy link

@Goldenflamer You can use this one if you want: https://github.com/crazy-max/docker-docker#about

Ty that works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.