Mesos, Docker and Consul
I was playing with Mesos/Marathon + Docker recently and tried to integrate Consul. Mesos sets the Docker container ‘name’ to a internal value that messes with the Consul Registrator, something like mesos-aa998abcabab
. Registrator can accept an environmental variable telling it what service name to register as instead. The format for that is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
gistfile1.txt
curl -v -X POST http://localhost:8080/v2/apps \
-H Content-Type:application/json -d '{
"id": "some-nginx",
"container": {
"docker": {
"parameters" : {
"env": "SERVICE_NAME=nginx-xyz"
},
"image": "nginx",
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 80, "hostPort": 0, "protocol": "tcp" }
]
},
"type": "DOCKER",
"volumes": []
},
"cpus": 0.2,
"mem": 128.0,
"instances": 1
}'
Registrator will register the instance with a service name of nginx-xyz
This post is licensed under
CC BY 4.0
by the author.