I am currently working on a team project utilizing Docker with Apache Mesos/Marathon. To deploy MySQL docker containers on Mesos/Marathon, we have to create a JSON file with port mapping. I have searched everywhere on the internet and just can't find any sample JSON file to look on for port mapping. Anyone have done this before?
Asked
Active
Viewed 1,757 times
0
-
Which of the four enormous systems you have mentioned is going to read the JSON? – Bryan Jan 29 '15 at 09:44
-
What are the four systems? Are you refering to init system (Marathon), cron (Chronos), service discovery (DNS), storage (HDFS)? – Hans Jan 30 '15 at 03:56
-
You mentioned Docker, Mesos, Marathon and MySQL in your question. All of them may do port mapping, and may need to read JSON. Please narrow down your question. – Bryan Jan 30 '15 at 09:47
1 Answers
1
Here's some example Marathon JSON for using Docker's bridged networking mode:
{
"id": "bridged-webapp",
"cmd": "python3 -m http.server 8080",
"cpus": 0.5,
"mem": 64.0,
"instances": 2,
"container": {
"type": "DOCKER",
"docker": {
"image": "python:3",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 8080, "hostPort": 0, "servicePort": 9000, "protocol": "tcp" },
{ "containerPort": 161, "hostPort": 0, "protocol": "udp"}
]
}
}
}
See the "Bridged Networking Mode" section in https://mesosphere.github.io/marathon/docs/native-docker.html for more details.

Adam
- 4,322
- 1
- 16
- 22
-
{ "id": "mysql1", "cmd": "/bin/bash /start.sh", "cpus": 0.5, "mem": 500, "instances": 1, "container": { "type": "DOCKER", "docker": { "image": "centos6mysql", "network": "BRIDGE", "portMappings": [ { "containerPort": 3306, "hostPort": 0, "servicePort": 0, "protocol": "tcp" } ] } } } – Hans Feb 02 '15 at 01:54
-
This is how I create the JSON file. However, after running the JSON file, it will just keep showing the Deploying task on my Marathon UI and my containers will keep failing to run. – Hans Feb 02 '15 at 01:57
-
It may help to pre-fetch the docker images on each slave, so that Mesos doesn't time out waiting for the `docker pull` to complete. You may also want to increase the `executor_registration_timeout`, since that includes the expected docker pull time. Example: `echo "5mins" | sudo tee /etc/mesos-slave/executor_registration_timeout` – Adam Feb 02 '15 at 23:43
-
1Also, I think you'll want to set a non-0 servicePort, as this is the cluster-wide port on which you expect to be able to locate your service, if using haproxy or similar for service discovery. – Adam Feb 02 '15 at 23:52