compose icon indicating copy to clipboard operation
compose copied to clipboard

failed to get console mode for stdout: The handle is invalid.

Open AnthonyMastrean opened this issue 5 years ago • 48 comments

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

  1. Create any Dockerfile on Windows
  2. Create any Docker Compose manifest with a build section pointing to the same Dockerfile
  3. 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.

image

AnthonyMastrean avatar Mar 09 '21 15:03 AnthonyMastrean

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

AnthonyMastrean avatar Mar 09 '21 15:03 AnthonyMastrean

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

ternavsky avatar Mar 10 '21 06:03 ternavsky

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

JorisDebonnet avatar Mar 10 '21 12:03 JorisDebonnet

same issue.

xiaohuahou avatar Mar 12 '21 02:03 xiaohuahou

same issue

kalvintera avatar Mar 12 '21 17:03 kalvintera

Same issue. Is there a way to prevent auto update?

jehadassaf avatar Mar 15 '21 10:03 jehadassaf

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)

ternavsky avatar Mar 15 '21 11:03 ternavsky

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

Myhael76 avatar Mar 15 '21 22:03 Myhael76

same issue.

sigmanil avatar Mar 16 '21 13:03 sigmanil

+1

bc3tech avatar Mar 16 '21 17:03 bc3tech

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.

nunoperalta avatar Mar 16 '21 22:03 nunoperalta

Same issue on windows docker desktop 3.2.2. image

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.

Warfront1 avatar Mar 19 '21 16:03 Warfront1

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

icavalheiro avatar Mar 25 '21 18:03 icavalheiro

Any update on what's happening with this? It's happening to all of my developers, and it's obscuring the logs.

ZukkyBaig avatar Mar 26 '21 14:03 ZukkyBaig

Same problem on my side. It would be great to get an update.

tvaudelin avatar Mar 31 '21 09:03 tvaudelin

Having this same issue and interested in a solution as well.

jski avatar Apr 02 '21 15:04 jski

seems error is triggered by https://github.com/containerd/console/blob/master/console_windows.go#L54

ndeloof avatar Apr 06 '21 14:04 ndeloof

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 :(

ndeloof avatar Apr 06 '21 15:04 ndeloof

+1

Westmorland avatar Apr 06 '21 19:04 Westmorland

same issue.

ro-anderson avatar Apr 07 '21 01:04 ro-anderson