dorinand
dorinand

Reputation: 1747

How to install buildx with docker 23.0.1

I am trying to install buildx from docker doc. At first, I tried Install using a Dckerfile. I have to say, I have no clue how to install it with this steps, the instructions is very poor for this section. So I pick option Download manually.

I downloaded buildx-v0.10.2.darwin-amd64 binary, copy it to $HOME/.docker/cli-plugins and rename it as docker-buildx and make it executable:

$ ll $HOME/.docker/cli-plugins/docker-buildx
-rwxr-xr-x 1 root root 55984928 Feb 14 20:05 /root/.docker/cli-plugins/docker-buildx*

All this steps are from documentation.

As next step, I wanted to Set Buildx as the default builder. According to the docs, I shuld run docker buildx install but it raised and exception 'buildx' is not a docker command:

$ docker buildx install
docker: 'buildx' is not a docker command.
See 'docker --help'

The instructions are very unclear to me and dont know how to fix it. I found this but its basically the same steps so its do not help.

Can anybody help me to find out, whats I am missing?

$ uname -m
x86_64

Docker version 23.0.1, build a5ee5b1

Upvotes: 18

Views: 66141

Answers (7)

Tombart
Tombart

Reputation: 32486

On Debian you can install plugin package (see official install instructions):

apt install docker-buildx-plugin

similar on RedHat/CentOS:

yum install docker-buildx-plugin

similar on Arch Linux:

pacman -S docker-buildx

then run:

docker buildx install

or update /etc/docker/daemon.json with (and restart docker service:systemctl restart docker):

{
  "features": {
    "buildkit" : true
  }
}

Then docker info should be showing something like this:

$ docker info | head -n8
Client: Docker Engine - Community
 Version:    24.0.6
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx

Upvotes: 15

reinisr
reinisr

Reputation: 1

This solution helped me:

# Add Docker's official GPG key
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Update package list with Docker repository
sudo apt-get update

# Now install Docker Buildx
sudo apt-get install -y docker-buildx-plugin

Upvotes: 0

Subash
Subash

Reputation: 611

I struggled badly to install docker buildx and finally got a reliable way.

This approach addresses the following,

  1. Install docker buildx for any user
  2. Installation on any distribution manually
  3. Convenient way to install buildx in a remote machine

Installation:

  • SSH to the remote machine and switch to root user
    ❯ sudo -i
  • Identify your linux architecture from client Docker version command
    ❯ docker version
    Client:
     Version:           20.10.17
     API version:       1.41
     Go version:        go1.17.11
     Git commit:        100c701
     Built:             Mon Jun  6 22:59:14 2022
     OS/Arch:           linux/arm64
     Context:           default
     Experimental:      true
    ...
    ...
  • Download the docker buildx binary of your linux arch, which is compatible to the installed Docker (Refer dependency changes under release page for compatible Docker)
    ❯ wget -nv https://github.com/docker/buildx/releases/download/v0.8.2/buildx-v0.8.2.linux-arm64
  • Create the cli-plugins folder. Replace <user> with your user, where buildx is required.
    ❯ mkdir -p /home/<user>/.docker/cli-plugins
  • Move the binary. Don't forget to rename the binary to docker-buildx like following, (It is a mandatory step)
    ❯ mv buildx-v0.8.2.linux-arm64 /home/<user>/.docker/cli-plugins/docker-buildx
  • Make the binary executable
    ❯ chmod a+x /home/<user>/.docker/cli-plugins/docker-buildx
  • Give ownership from root to your user
    ❯ chown -v -R <user> /home/<user>
  • Confirm the Docker buildx installation with Docker info command.
    ❯ docker info | head -n7
    Client:
     Context:    default
     Debug Mode: false
     Plugins:
      buildx: Docker Buildx (Docker Inc., v0.8.2)
      compose: Docker Compose (Docker Inc., v2.5.1)
    ❯

Upvotes: 1

deadcoder0904
deadcoder0904

Reputation: 8693

I had to simply do sudo apt install docker-buildx & then did wsl --shutdown.

After that, I tried docker build . -t node-app which worked without showing the error:

DEPRECATED: The legacy builder is deprecated and will be removed in a future release. Install the buildx component to build images with BuildKit: https://docs.docker.com/go/buildx/

Upvotes: 11

Shubham Jain
Shubham Jain

Reputation: 17603

Docker Engine package repositories contain Docker Buildx packages when installed according to the Docker Engine install documentation. Install the docker-buildx-plugin package to install the Buildx plugin.

Still if you want to Manual download then follow below steps

  • Download buildx binary from below URL as per your OS architecture :

    https://github.com/docker/buildx/releases/

  • Rename the binary to docker-buildx

  • Place the binary in the below path : $HOME/.docker/cli-plugins

  • Set the environment path and source the file

Source:

https://github.com/docker/buildx#installing


Commands logs:

$ docker buildx version
    github.com/docker/buildx v0.10.5 86bdced7766639d56baa4c7c449a4f64684787

$ docker info 
Client:
 Version:    24.0.2-rd
 Context:    default
 Debug Mode: false
 -----
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.5
    Path:     /Users/Shubh/.docker/cli-plugins/docker-buildx
 -----
  compose: Docker Compose (Docker Inc.)
    Version:  v2.18.1
    Path:     /Users/Shubh/.docker/cli-plugins/docker-compose
 

Upvotes: 0

OnyxHalo
OnyxHalo

Reputation: 11

Try this.

  1. Download buildx-v0.10.2.darwin-amd64 to $HOME/.docker/cli-plugins
  2. Don't rename it
  3. Run the following command: $ docker buildx install

See if it works.

Upvotes: 1

Kevin T.
Kevin T.

Reputation: 39

first execute

~/.docker/cli-plugins/docker-buildx

and see if you can execute it. if it is not executable then docker buildx install will fail

Upvotes: -2

Related Questions