Docker container is killed after ~1 minute

I made a very small Phoenix Framework app (only slightly modified from what you get when you run: mix I’ve been trying to deploy it in a Docker container. It works fine while the container is running, but it always dies within a minute of startup with a message of “Killed.” Whether I make requests to it or not does not seem to matter. I tried watching the docker events, and got the following:

$ docker events
2016-04-09T16:24:02.538602484-04:00 container create 
(, name=amazing_bhabha)

2016-04-09T16:24:02.550438045-04:00 container attach
(, name=amazing_bhabha)

2016-04-09T16:24:02.599731705-04:00 network connect 
(name=bridge, type=bridge, container=ef45a768723c64125c717a7b40ee7513e477f27339c6266bd28cc3084c60e11f)

2016-04-09T16:24:02.600048755-04:00 container start
(, name=amazing_bhabha)

2016-04-09T16:24:53.858352733-04:00 container die 

2016-04-09T16:24:53.930349810-04:00 network disconnect
(container=ef45a768723c64125c717a7b40ee7513e477f27339c6266bd28cc3084c60e11f, name=bridge, type=bridge)

I’m still very new to Docker and Elixir, so I’m not sure what other research I can do into this. There is a similar sounding question here: I run a docker container,but after few minutes , it was killed by himself

  • Can't connect Docker + PostgreSQL 9.3
  • Not able to create report on protractor tests in docker container
  • Is it possible to dockerize Internet Explorer?
  • All external DNS queries fail from within docker container
  • Docker Node JS Installation
  • Is Docker complementary or competitive to Spring Boot / Dropwizard? [closed]
  • But I’m not sure how or if the OP ever resolved it. Thanks in advance for any hints. Please let me know if there’s any other information I can get that might help.

    Edit 1: I learned that docker ps -a will actually tell me the exit code, which I haven’t found elsewhere. All of my containers are exiting with a 137 error code. My docker VM has 4GB of memory, so I tried running with a -m=3g flag but got the same result. I also did not see any processes in the Windows process explorer approach 3GB.

    Edit 2: I played around a bit more with the memory limit on my container and found that the time the container lives is directly correlated to how much memory I allow it. So I created a totally new project (mix –no-brunch –no-ecto,copied my Dockerfile, and tried to build and run it. It gave me exactly the same results. This leads me to believe that my problem is in my Dockerfile or how I’m running the app.


    FROM marcelocg/phoenix
    MAINTAINER Arcaten
    RUN echo $PWD
    #Copy source
    ADD . ./
    #Get dependencies
    RUN yes | mix local.hex
    RUN yes | mix deps.get
    RUN yes | mix compile
    RUN ls -l
    EXPOSE 4000
    #Run server
    ENTRYPOINT yes | MIX_ENV=dev mix phoenix.server


    docker build -t hello_phoenix .


    docker run -p 4000:4000 -m=512m hello_phoenix

    And with that, it runs for about 7 seconds and exits with a 137 error code.

    Edit 3: Since I was getting “OOMKill”:true in my containers, I tried moving in the other direction. I removed the memory cap from my run commands. I still get the same result, but now “OOMKill” is set to false and all of the memory numbers from my inspects now read 0. Also, the StopSignal is now set to “15”

  • Docker container keeps growing
  • Concourse CI Pipeline giving error :- Get net/http: request canceled while waiting for connection
  • Does Docker override files?
  • Docker selenium/node-chrome - Protractor can not find Chrome binary
  • Connect to Docker container running mysql on Windows 10
  • Docker: /etc/hosts not automatically updated on source container restart
  • 2 Solutions collect form web for “Docker container is killed after ~1 minute”

    The problem is the yes | part.
    The Erlang VM behaves differently from regular programs when it comes to the stdin and input. It will buffer whatever input you throw at it, and with yes | you give it an infinite stream of yeses. Those yeses are buffered and memory grows until the process is killed by the system, because there’s no more memory left.

    It is generally a bad idea to use yes | with anything using Elixir/Erlang, even more so with long running tasks – with short running ones you have a chance at completing them before you run out of memory, but it’s still not a great idea.

    Not sure if this is still relevant but the whole infinite stream problem seems to be solved by just piping echo y.


    echo y | mix compile

    Although I’m not sure if there’s something I’m missing that makes this a silly solution.

    EDIT: this is probably better

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.