ERROR: failed to authorize: failed to fetch oauth token: Post "https://auth.docker.io/token": dial tcp: lookup auth.docker.io on 172.18.16.1:53: read udp 172.18.16.50:47159->172.18.16.1:53: i/o timeout

I am trying to launch docker compose up --build from my cmd terminal. unfortunately, the .py file in which I have my " docker compose up --build" do run with the error below:

ERROR: failed to authorize: failed to fetch oauth token: Post “https://auth.docker.io/token”: dial tcp: lookup auth.docker.io on 172.18.16.1:53: read udp 172.18.16.50:47159->172.18.16.1:53: i/o timeout

To be more concise, if i run the command directly, the server fires without any error, however, when I create a python file with the subprocess.call to run the same command, the error appears.

I am using Docker Desktop

Docker Desktop 4.26.1 (131620) is currently the newest version available.

#1 [map2loop internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.05kB 0.0s done
#1 DONE 0.0s

#2 [map2loop internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [map2loop internal] load metadata for docker.io/continuumio/miniconda3:latest
#3

#4 [map2loop auth] continuumio/miniconda3:pull token for registry-1.docker.io
#4 DONE 0.0s

#3 [map2loop internal] load metadata for docker.io/continuumio/miniconda3:latest
#3 ERROR: failed to authorize: failed to fetch oauth token: Post “https://auth.docker.io/token”: dial tcp: lookup auth.docker.io on 172.18.16.1:53: read udp 172.18.16.50:47159->172.18.16.1:53: i/o timeout

[map2loop internal] load metadata for docker.io/continuumio/miniconda3:latest:


I tried searching, but none of similar issue have been solved. Is there anyone who have managed to solve this issue?

After several attempt, to fix the above issue, I have to do the following:

To manually enable buildkit on my window machine, you execute the two commands in your console:

setx DOCKER_BUILDKIT 1
setx COMPOSE_DOCKER_CLI_BUILD 1

With those variables set in your shell, you can now run docker-compose build using BuildKit.

Then run: docker compose up --build

Note: Once your docker is down, to start it you need to re-run all the 3 above commands in the same order to have it build the new docker container.

In different environment you can execute in your console:

export DOCKER_BUILDKIT=1

export COMPOSE_DOCKER_CLI_BUILD=1

Also if you are interested in running the command via python, you can type the below:
os.system(‘start cmd /K setx COMPOSE_DOCKER_CLI_BUILD 1 & setx DOCKER_BUILDKIT 1 & docker compose up --build’)