Compose: Ctrl-C/SIGINT has erratic behaviour on "docker-compose up"

Created on 13 Apr 2016  ·  30Comments  ·  Source: docker/compose

Atleast since version 1.6.0 I have had erratic behaviour when pressing ctrl-c to stop a "docker-compose up". Sometimes the containers are stopped gracefully, and sometimes it "aborts", leaving all the containers running.

I'm still seeing the issue in docker-compose 1.6.2 with docker 1.10.3.

The following is the input and output in my terminal:

$ docker-compose up
Starting masqueradeservice_masquerade_1
Attaching to masqueradeservice_masquerade_1
masquerade_1 | [2016-04-13 07:15:50,600] [INFO]: Server started at http://0.0.0.0:7777
^CGracefully stopping... (press Ctrl+C again to force)
Stopping masqueradeservice_masquerade_1 ... done
$ docker-compose up
Starting masqueradeservice_masquerade_1
Attaching to masqueradeservice_masquerade_1
masquerade_1 | [2016-04-13 07:16:02,684] [INFO]: Server started at http://0.0.0.0:7777
^CERROR: Aborting.
$ docker ps
CONTAINER ID        IMAGE                          COMMAND              CREATED             STATUS              PORTS                    NAMES
0b6551bb0b31        masqueradeservice_masquerade   "python server.py"   9 minutes ago       Up 20 seconds   0.0.0.0:7777->7777/tcp   masqueradeservice_masquerade_1
areup kinbug

Most helpful comment

Still getting this issue on Mac OS.

Docker version 18.09.0, build 4d60db4
docker-compose version 1.23.1, build b02f1306

Sometimes ctrl+c exits all running Docker containers. Sometimes it just states 'aborting...' and leaves all containers running.

All 30 comments

Same here - docker 1.10.3, docker-compose 1.6.2, Ubuntu 15.10.

See #2904 for more background. A partial fix went in to 1.7.0 (which is being released this week). It doesn't completely fix the issue with pyinstaller, but it does restore it to the pre-1.6.x behaviour, which saw the bug a lot less frequently.

I'll leave this open for now. If you could try it out with 1.7.0-rc2 that would be great.

I actually found tty: true did the trick for me. But then...
image

Docker Compose 1.7.0 fixes this issue for me. Thanks!

I still get this problem with docker-compose version 1.8.0-rc2, build c72c966
with one of my database containers, the issue can be reliably reproduced. Is there some way I can help by dumping a log or something?

More on this topic:
https://github.com/docker/compose/issues/3347
https://github.com/docker/compose/issues/1040
https://github.com/docker/compose/issues/2904

I seem to be experiencing the same issue with docker-compose version 1.8.1, build 878cff1.

Yeap, same here getting this issue with docker-compose version 1.8.0.

I am observing this with docker-compose version 1.8.1, build 878cff1. It happens about 50% of the time running a microsoft/dotnet:runtime container and a postgres:latest container together.

I'm on OSX docker-compose version 1.9.0, build 2585387 and it's very broken

1.10.0 on OSX continues to demonstrate this problem.

Same for 1.11.2

+1 for 1.11.2

Seeing this too. On OSX w/ Docker For Mac 17.05.0-ce-rc1-mac8 (16582). Details from docker-compose version.

docker-compose version 1.12.0, build b31ff33
docker-py version: 2.2.1
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

Looks like https://github.com/docker/compose/issues/3347 is a duplicate of this one and is open. So will post there as well.

Happening for me too.

$ docker-compose version
docker-compose version 1.18.0, build 8dd22a9
docker-py version: 2.6.1
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

$ docker --version
Docker version 17.12.0-ce, build c97c6d6

OS X version 10.13.3 (17D102)

Confirmed it's still happening here too on OS X.

❯ docker-compose version
docker-compose version 1.20.1, build 5d8c71b
docker-py version: 3.1.4
CPython version: 3.6.4
OpenSSL version: OpenSSL 1.0.2n  7 Dec 2017

❯ docker --version
Docker version 18.03.0-ce, build 0520e24

OS X version 10.13.3 (17D102)

Same on OS X 10.13.4

docker-compose --version
docker-compose version 1.20.1, build 5d8c71b

docker --version
Docker version 18.03.0-ce, build 0520e24

Same on OSX 10.13.1
Docker Version 18.03.1-ce-mac65 (24312)
docker-compose version 1.21.1, build 5a3f1a3
docker-py version: 3.3.0
CPython version: 3.6.4

tty: true did not help.

This is also an issue for me.

Same for me. As suggested by @mcgeeco adding tty: true to one of my services in the compose file fixed it.

This has been an issue for me for years now. Adding tty: true to one or all of the services does not seem to help. This issue should be reopened.

Does anyone have any ideas as to what is causing this error?

Turned out, tty: true did not solve the problem permanently. It was good for some time but somehow now happens again.

I ended up working with a bash alias to ensure the containers are shut down.

alias docker-compose-up="bash -c \"trap 'docker-compose down' EXIT; docker-compose up\""

Still getting this issue on Mac OS.

Docker version 18.09.0, build 4d60db4
docker-compose version 1.23.1, build b02f1306

Sometimes ctrl+c exits all running Docker containers. Sometimes it just states 'aborting...' and leaves all containers running.

I encountered same problem on Arch Linux.

docker-compose version is 1.23.2.
docker version 18.09.3-ce

Same python program (python 3.7) behaves different if it is launched by docker-compose up. Program expects to catch a graceful shutdown and do some stuff before exit. It runs on host machine as it is expected. If it is launched by docker-compose, it never reaches / runs graceful shutdown part. Eventually it exits, but not gracefully.

I am encountering this on macOS Mojave (10.14.4).

docker-compose version 1.23.2, build 1110ad01
Docker version 18.09.2, build 6247962

I usually get the expected

^CGracefully stopping... (press Ctrl+C again to force)
Stopping SERVICENAME ... done

But, sometimes I get

^CERROR: Aborting.

I am also having this issue

This isn't limited to OS X – I'm experiencing it with docker-compose 1.18.0 on Ubuntu Xenial.

The same for:

Docker version 18.09.2, build 6247962
docker-compose version 1.23.2, build 1110ad01
ProductName:    Mac OS X
ProductVersion: 10.14.5
BuildVersion:   18F203

Same here:

docker-compose version 1.25.2, build 698e2846

on macOs

Was this page helpful?
0 / 5 - 0 ratings