I made a very small Phoenix Framework application (only slightly modified from what you get when you start: mix phoenix.new). I am trying to deploy it in a Docker container. It works fine while the container is running, but it always dies within a minute after starting up with the message βKilledβ. Whether I make requests to it or not, it doesn't seem to matter. I tried to watch docker events and got the following:
$ docker events 2016-04-09T16:24:02.538602484-04:00 container create ef45a768723c64125c717a7b40ee7513e477f27339c6266bd28cc3084c60e11f (image=gcr.io/myprojectname/myapp:v2, name=amazing_bhabha) 2016-04-09T16:24:02.550438045-04:00 container attach ef45a768723c64125c717a7b40ee7513e477f27339c6266bd28cc3084c60e11f (image=gcr.io/myprojectname/myapp:v2, name=amazing_bhabha) 2016-04-09T16:24:02.599731705-04:00 network connect c64a1439c8095f82ab0fea5c48b563c8aac7256d6064b3189b0bc8d052d69fe4 (name=bridge, type=bridge, container=ef45a768723c64125c717a7b40ee7513e477f27339c6266bd28cc3084c60e11f) 2016-04-09T16:24:02.600048755-04:00 container start ef45a768723c64125c717a7b40ee7513e477f27339c6266bd28cc3084c60e11f (image=gcr.io/myprojectname/myapp:v2, name=amazing_bhabha) 2016-04-09T16:24:53.858352733-04:00 container die ef45a768723c64125c717a7b40ee7513e477f27339c6266bd28cc3084c60e11f (name=amazing_bhabha, image=gcr.io/myprojectname/myapp:v2) 2016-04-09T16:24:53.930349810-04:00 network disconnect c64a1439c8095f82ab0fea5c48b563c8aac7256d6064b3189b0bc8d052d69fe4 (container=ef45a768723c64125c717a7b40ee7513e477f27339c6266bd28cc3084c60e11f, name=bridge, type=bridge)
I'm still very new to Docker and Elixir, so I'm not sure what other studies I can do about this. There is a similar sound question here: I am launching a docker container, but after a few minutes he was killed by himself .
But I'm not sure how or when the OP has ever resolved this. Thanks in advance for any tips. Please let me know if there is any other information I can get that might help.
Edit 1: I found out that docker ps -a will actually tell me the exit code that I haven't found elsewhere yet. All my containers exit with error code 137. My docker VM has 4 GB of memory, so I tried working with the -m = 3g flag, but got the same result. I also did not see any processes in Windows explorer go to 3GB.
Edit 2: I played around a bit with the memory limit on my container and found that the container's lifetime directly correlates with how much memory I allow it. So I created a completely new project (mix --no-brunch --no-ecto phoenix.new), copied my Dockerfile, and tried to create and run it. This gave me exactly the same results. This makes me think that my problem is in my Dockerfile or how I launch the application.
Dockerfile:
FROM marcelocg/phoenix MAINTAINER Arcaten RUN echo $PWD #Copy source ADD . ./ #Get dependencies RUN yes | mix local.hex RUN yes | mix deps.get #compile RUN yes | mix compile RUN ls -l EXPOSE 4000 #Run server ENTRYPOINT yes | MIX_ENV=dev mix phoenix.server
Addition:
docker build -t hello_phoenix .
Run:
docker run -p 4000:4000 -m=512m hello_phoenix
And with this, it works for about 7 seconds and exits with error code 137.
Edit 3: Since I was getting "OOMKill": true in my containers, I tried to move in the other direction. I removed the memory cap from my launch commands. I still get the same result, but now the OOMKill parameter is set to false, and all the memory numbers from my checks are now read 0. In addition, StopSignal is now set to 15