I have a CoreOS cluster in which i have a SystemD service that just run a Docker container. However, for flexibility purpose, i want the Docker Registry the container gets pulled from to be discovered when the service start, what i do easily using Etcd (the node discovery system from the CoreOS project).

So, i tried it in a normal terminal, what just gives me a command like this /usr/bin/etcdctl get /services/registryto get the current IP address of the registry. And it works! But from a SystemD service, the command is returned as typed and not executed as someone should do in a Shell script with backticks. I tried backticks, $() and ${}syntaxes but the command is still returned as is.

If anybody has a suggestion, i'm taking it :) Thanks!

up vote 3 down vote accepted

If you make your ExecStart use /bin/sh -c "echo $(etcdctl ls /)" it will perform in the way that you desire.

Here's a full unit file taking advantage of this: https://github.com/coreos/unit-examples/blob/master/simple-fleet/apache-discovery.2.service#L6

  • Thanks, @Deer Hunter & @Rob! It works :) It seems Systemd does not support string extrapolation ... – phndiaye Oct 8 '14 at 11:10

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.