Docker when deployed on marathon is failing continously

221 views Asked by At

I am new to these technologies and trying to figure things out. So, I followed the basic tutorials provided by Mesosphere and was able to create a cluster locally (two VMs) now I want to deploy a nodejs application so I created a docker image which contains nodejs express framework and a script which just start the server. You can find the docker image at docker registry as pujariamol/nodejs-express and it has a script at root level called as runScript.sh.

The JSON that I tried for deploying it is as follows:

{
    "id": "app4", 
    "container": {
        "type":"DOCKER",
      "docker": {
        "image": "pujariamol/nodejs-express"
      }
    },
    "cmd":"echo hello > /tmp/out.txt",
    "cpus": 0.25,
    "mem": 512.0,
    "instances": 1
}

I thought this will pull my docker container and will start it. Also, I wanted to run runScript.sh so I was trying './runScript.sh' in cmd but it didn't work so I tried writing some text in out.txt for testing purpose but nothing seems to work. The moment the application is deployed the mesos shows Failed status for this app. I am using chrome extension postman for deploying it on marathon. I have no idea what is going wrong. Please help me with getting this application deployed on Marathon and let me know if you need any more information.

Thanks in advance.

2

There are 2 answers

0
larsks On

I don't know Mesosphere at all, but if you are trying to run this in a container:

echo hello > /tmp/out.txt

...then your container is going to be very, very short lived. A Docker container only runs as long as your initial command, and echo is simply going to exit immediately.

Are you able to start the container successfully using docker run by itself, without involving mesosphere? Have you looked at the container logs to see if there are any useful errors? You can use docker logs for this, and it's possible that Mesosphere provides an interface to this information.

If you are trying to run ./runScript.sh, are you certain that there is a script named runScript.sh in the current directory when the container starts? It would have to be located in the root directory (/) for this to work. It's generally better to provide a full path to your initial command (e.g., /runScript.sh, or /usr/local/something/runScript.sh).

0
Amol Pujari On

Thank you Larsks for the reply. Yes I checked the container and scripts individually they were working fine. Though it is working now, I am not sure if this is the reason. So, I assume it was happening because I was running the container on my virtual machine and I was creating a job from a postman which was on my host machine (Windows8) and it never worked for runScript.sh. So, I tried it from within the VM using CURL cmd and it worked and I can access the container server too just that I have to find out the container IP address and then try to access it. So now will be trying to figure out how to access these servers from a single URL. Anyway thank you Larsks, I didn't know that the containers will be short lived for such commands before I read your comment.