0

I am running a command to start a docker container like "docker run -p 8080:8080 tomcat:7.0" using the marathon UI. Marathon does deploy the container to one of my slave nodes, however, it keeps trying to start a container again and again and repeatedly fails. Fails because its not able to bind to port 8080 as tomcat is already running from the first container deployed by the marathon framework.

The docker command i ran is running in the foreground mode and tomcat is running at port 8080, so marathon shouldn't be trying to restart. Any thoughts why is this happening?

Thanks

user3012653
  • 85
  • 1
  • 13

1 Answers1

0

Marathon does deploy the container to one of my slave nodes, however, it keeps trying to start a container again and again and repeatedly fails.

It wouldn't try to deploy another container unless you've requested for its multiple instances. Or if earlier container failed to deploy or got killed for some reason. If you're specifically trying to have more instances then binding it to port 8080 is going to fail as you mentioned.

so marathon shouldn't be trying to restart

It doesn't seem to trying to restart. You said one container is already deployed and listening on 8080. So this should be a different container. Can you update the question with the json file you're posting to Marathon's REST API to start the Docker containers?

Dharmit
  • 5,498
  • 2
  • 27
  • 30
  • Thanks @Dharmit. I was using marathon UI to run a docker instance like "docker run -p 8080:8080 tomcat". this would ensure docker runs tomcat in foreground and i found marathon was trying to launch multiple instance of the same container and failed repeatedly (yesterday). i re-installed the whole environment and tried now and it works as expected. It's not launching more than 1 instance which is what i asked marathon to do it in the first place. – user3012653 Aug 27 '15 at 16:41
  • I never had success launching docker containers with json though. If i submit a json like { "id": "tomcat", "instances": "1", "cpus": "0.5", "mem": "512", "container": { "type": "DOCKER", "docker": { "image": "tomcat:7.0" } } } marathon always waits at 0/1 and never deploys it to the mesos-slaves. i have no idea which logs to refer to for the failure reason. – user3012653 Aug 27 '15 at 16:51
  • Interesting. I have always had success deploying Docker containers using Marathon REST API and json file. Did you check if the image was available on the slaves? Maybe image download is taking time which in turn makes you feel that it's not working. As for logs, you can check slave logs for the slave on which Marathon tried to deploy the container. Or, you can click on the Sandbox link in Mesos UI and refer stdout/stderr. – Dharmit Aug 28 '15 at 05:44
  • Check the task_launch_timeout setting used by marathon when trying to run docker containers. If it is too low (in milliseconds) the task will be seen as a failure if the container takes too long to spin up. Look at /etc/marathon/conf for a task_launch_timeout file with single value setting like "300000". See "Configure Marathon" section here https://mesosphere.github.io/marathon/docs/native-docker.html – njappboy Jul 08 '16 at 13:51