CoreOS Systemd sidekick unit unable to start

Solution 1:

I was able to correct the error by using single quotes around the /bin/bash -c command, using double quotes around the --format and double escape the port number. The final full ExecStart command is:

ExecStart=/bin/bash -c '\
while true; do \
  etcdctl set /services/tomcat/tomcat-%i/ip ${COREOS_PRIVATE_IPV4}:$(docker inspect --format="{{(index (index .NetworkSettings.Ports \\"8080/tcp\\") 0).HostPort}}" tomcat.%i) --ttl 180; \
  etcdctl set /services/bind/tomcat-%i ${COREOS_PRIVATE_IPV4} --ttl 180; \
sleep 60; \
done'