failed to get console mode for stdout: The handle is invalid.
Description of the issue
The docker-compose build command prints this failed error every time.
Context information (for bug reports)
Output of docker-compose version
docker-compose version 1.27.4, build 40524192
docker-py version: 4.3.1
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.1c 28 May 2019
Output of docker version
Client: Docker Engine - Community
Version: 20.10.2
API version: 1.41
Go version: go1.13.15
Git commit: 2291f61
Built: Mon Dec 28 16:14:16 2020
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.2
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 8891c58
Built: Mon Dec 28 16:15:28 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Output of docker-compose config
(Make sure to add the relevant -f and other flags)
services:
web:
build:
context: C:\Users\anthony\example
dockerfile: Dockerfile
version: '2.4'
and the Dockerfile can be anything, this works
FROM nginx:stable
Steps to reproduce the issue
- Create any Dockerfile on Windows
- Create any Docker Compose manifest with a build section pointing to the same Dockerfile
- Run
docker-compose build
Observed result
The Docker Compose build command always prints the failed line. Nothing else seems to be wrong, but I'm not sure.
WARNING: Native build is an experimental feature and could change at any time
Building web
failed to get console mode for stdout: The handle is invalid.
[+] Building 0.1s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 31B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/nginx:stable 0.0s
=> CACHED [1/1] FROM docker.io/library/nginx:stable 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:b3914da1a942520904ff755103e5eb24c87fee1a5af36 0.0s
=> => naming to docker.io/library/downloads_web 0.0s
Expected result
The plain Docker build command works as expected.
[+] Building 0.1s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 31B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/nginx:stable 0.0s
=> CACHED [1/1] FROM docker.io/library/nginx:stable 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:b3914da1a942520904ff755103e5eb24c87fee1a5af365037b7fa48e38c6a16e 0.0s
=> => naming to docker.io/library/web
Stacktrace / full error message
failed to get console mode for stdout: The handle is invalid.
Additional information
OS version / distribution, docker-compose install method, etc.

I noticed this warning message only appears when running Docker Compose commands. It looks like both Docker and Docker Compose merged changes to use native build / buildx by default now. Why is this warning still here?
WARNING: Native build is an experimental feature and could change at any time
And why does the handle error disappear when I turn off native build?
PS> [System.Environment]::SetEnvironmentVariable('COMPOSE_DOCKER_CLI_BUILD', '0', 'Process')
PS> docker-compose build
Building web
Step 1/1 : FROM nginx:stable
---> 05f64a802c26
Successfully built 05f64a802c26
Successfully tagged downloads_web:latest
Same for me. After yesterday update console output for docker-compose build changed. And it throws "failed to get console mode for stdout: The handle is invalid."
Windows 10 Docker Desktop 3.2.1
Fallback to Docker Desktop 3.1.0 helped
I had the same issues since upgrading to 3.2.1 yesterday (on Windows 10). Aside of that failed message, my builds also seemed to hang on one specific line, so I also reverted to version 3.1.0.
Afterwards I figured that the line probably just takes a long time and it would actually have completed ... but 3.1.0 shows the console output I'm used to, which gives a more comfortable feeling: it's "clearly still doing stuff and not just hanging". So this does indeed feel like a serious issue.
(The screenshot in the OP confuses me a bit, because it shows 3.1.0, while the issue for ternavsky and I only appeared on 3.2.1.)
same issue.
same issue
Same issue. Is there a way to prevent auto update?
Same issue. Is there a way to prevent auto update?
I just deny Docker desktop to make changes in the system on startup. After that you should run Docker by yourself, cause autostart won't work. After a minute it continues to threat me that it will be updated on the next reboot)
I noticed this warning message only appears when running Docker Compose commands. It looks like both Docker and Docker Compose merged changes to use native build / buildx by default now. Why is this warning still here?
WARNING: Native build is an experimental feature and could change at any timeAnd why does the handle error disappear when I turn off native build?
PS> [System.Environment]::SetEnvironmentVariable('COMPOSE_DOCKER_CLI_BUILD', '0', 'Process') PS> docker-compose build Building web Step 1/1 : FROM nginx:stable ---> 05f64a802c26 Successfully built 05f64a802c26 Successfully tagged downloads_web:latest
Same fore me. In normal command window this works:
set COMPOSE_DOCKER_CLI_BUILD=0
docoker-compose build
If I put the variable on 1 it gives the handle error.
I updated today, March 15th
c:\>docker-compose version
docker-compose version 1.28.5, build c4eb3a1f
docker-py version: 4.4.4
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
same issue.
+1
Great suggestion above.
In VS Code, I'm adding to the workspace settings:
"terminal.integrated.env.windows": {
"COMPOSE_DOCKER_CLI_BUILD": "0"
},
The first time, VS Code will ask if you allow setting this variable, when you open the terminal. Press "Allow", kill the terminal and restart the terminal.
"docker-compose build" will now work properly.
Same issue on windows docker desktop 3.2.2.

The most upsetting part of this all is how docker just auto updated. Previously I would wait numerous months after a update, to actually update my docker, to avoid these kind of small bugs. I would typically update on another test development machine, prior to updating my actual development machine to ensure there are no bugs on the latest version. We really need a way to opt out of updates, as this can really kill productivity.
This is actually driving me crazy, I have so many developers affected because of this... Setting COMPOSE_DOCKER_CLI_BUILD to 0 actually breaks it (same error we get when docker service is not initialized).
Any update on what's happening with this? It's happening to all of my developers, and it's obscuring the logs.
Same problem on my side. It would be great to get an update.
Having this same issue and interested in a solution as well.
seems error is triggered by https://github.com/containerd/console/blob/master/console_windows.go#L54
I expected this could be fixed by running build with --progress=plain, but unfortunately error persists. There might be another piece of code using ConsoleFromFile :(
+1
same issue.