tutor icon indicating copy to clipboard operation
tutor copied to clipboard

Change command to reset build context

Open misilot opened this issue 1 year ago • 5 comments

When I tried to run the specified command, docker told me to run docker context use default

misilot avatar Feb 20 '24 15:02 misilot

What's the full error message you got?

regisb avatar Feb 21 '24 08:02 regisb

(.venv) ➜ tutor-nla-theme git:(nla-v17) ✗ docker buildx use default ERROR: run docker context use default to switch to default context (.venv) ➜ tutor-nla-theme git:(nla-v17) ✗ docker context use default default Current context is now "default"

misilot avatar Feb 21 '24 13:02 misilot

What's your Docker version?

regisb avatar Feb 22 '24 10:02 regisb

What's your Docker version?

Docker version 25.0.3, build 4debf41

misilot avatar Feb 22 '24 13:02 misilot

That's strange. The docker buildx use command is not deprecated in Docker 25.0.3, as far as I know: https://github.com/docker/buildx/blob/master/docs/reference/buildx_use.md https://docs.docker.com/engine/release-notes/25.0/ https://docs.docker.com/build/release-notes/

I can't reproduce the issue on my machine. I'm running Docker 25.0.3 as well, with docker buildx version==v0.12.1. I'm wondering if you have a "default" builder at all? You can check with:

docker buildx ls

regisb avatar Feb 27 '24 06:02 regisb

While there are some issues with 'default' instance on my system, I am also seeing the mentioned error. I am also using Docker 25.0.3, on Mac.

> docker buildx ls           
NAME/NODE       DRIVER/ENDPOINT  STATUS   BUILDKIT PLATFORMS
dawoudsheraz    docker-container                   
  dawoudsheraz0 desktop-linux    inactive          
default *                        error             
desktop-linux   docker                             
  desktop-linux desktop-linux    running  v0.12.5  linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6

Cannot load builder default *: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

> docker buildx use desktop-linux
ERROR: run `docker context use desktop-linux` to switch to context desktop-linux

> docker context use desktop-linux
desktop-linux
Current context is now "desktop-linux"

DawoudSheraz avatar Mar 19 '24 11:03 DawoudSheraz

@misilot do you run macOS?

EDIT: given that the command still exists I don't understand why it would report to use docker context use instead.

regisb avatar Mar 26 '24 11:03 regisb

@regisb, yes I am running macOS

misilot avatar Mar 26 '24 12:03 misilot

What's the output of docker buildx ls?

regisb avatar Mar 27 '24 11:03 regisb

What's the output of docker buildx ls?

NAME/NODE       DRIVER/ENDPOINT             STATUS   BUILDKIT PLATFORMS
default         docker
  default       default                     running  v0.12.5  linux/arm64, linux/amd64, linux/amd64/v2, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
desktop-linux * docker
  desktop-linux desktop-linux               running  v0.12.5  linux/arm64, linux/amd64, linux/amd64/v2, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6

misilot avatar Mar 27 '24 13:03 misilot

The command docker buildx use still exists. However, to revert to the default context, we need to use the context command. When switching to a non-default context, we can utilize buildx.

https://github.com/docker/buildx/pull/39/files

hamza-56 avatar Apr 15 '24 14:04 hamza-56

The command docker buildx use still exists. However, to revert to the default context, we need to use the context command. When switching to a non-default context, we can utilize buildx.

https://github.com/docker/buildx/pull/39/files

Right. I think we can make the docs explicit that we need to use docker context use default specifically to switch back to default but can use buildx to switch to non-default contexts.

DawoudSheraz avatar Apr 16 '24 07:04 DawoudSheraz

Builders and contexts are different things, so don't think that we should be recommending to switch context by default.

I just saw this part of the docker buildx use documentation:

Alternatively, a context name can be used to switch to the default builder of that context.

If I understand correctly, docker buildx will first check if the argument corresponds to a different context name. Thus, I am able to reproduce the issue by switching to a different context, first:

$ docker context create pouac --docker from=default
pouac
Successfully created context "pouac"
{09:25:40:caffeine}~$ docker context ls
NAME        DESCRIPTION                               DOCKER ENDPOINT               ERROR
default *   Current DOCKER_HOST based configuration   unix:///var/run/docker.sock   
pouac                                                 unix:///var/run/docker.sock   
$ docker context use pouac
pouac
Current context is now "pouac"
$ docker buildx use max4cpu
$ docker buildx use default
ERROR: run `docker context use default` to switch to default context

@misilot what is the output of docker context ls for you?

regisb avatar Apr 16 '24 07:04 regisb

➜  ~ docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                 KUBERNETES ENDPOINT   ORCHESTRATOR
default             moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock
desktop-linux *     moby                Docker Desktop                            unix:///Users/tmisilo/.docker/run/docker.sock

Is what I have currently on my laptop (macos)

misilot avatar Apr 16 '24 13:04 misilot

This confirms my assumption. Docker recommends that you run docker context use instead of docker buildx use when you have a custom context that you are currently using. As a consequence, I don't think that docker context use should be the general recommendation.

regisb avatar Apr 16 '24 14:04 regisb

Sounds good. I'll go with Docker is just creating custom contexts on it's own since I believe those are the default from an install :)

misilot avatar Apr 16 '24 14:04 misilot

Based on the conversations above, it seems no further action is required. Closing this out. Feel free to re-open/open a new one if some changes in docs are still needed.

DawoudSheraz avatar Apr 30 '24 11:04 DawoudSheraz