Quantcast
Channel: linuxadmin: Expanding Linux SysAdmin knowledge
Viewing all articles
Browse latest Browse all 17835

[Help] Host IP in systemd service file

$
0
0

Hey everyone,

I'm currently writing a systemd service file which should start a docker container. Because I want to be able to start this service in a coreos cluster via fleet, I need to know the IP address of the machine that service is started on.

I tried something like that:

[Service] TimeoutStartSec=0 Environment="HOST_IP=$(hostname -i)" ETCD_HOST=127.0.0.1:4001 ExecStartPre=-/usr/bin/docker kill docker-register ExecStartPre=-/usr/bin/docker rm docker-register ExecStartPre=/usr/bin/docker pull jwilder/docker-register ExecStart=/usr/bin/docker run --name docker-register -d -e HOST_IP=$HOST_IP -e ETCD_HOST=$ETCD_HOST -v /var/run/docker.sock:/var/run/docker.sock -t jwilder/docker-register 

But that just gives me the String "$(hostname -i)" when reading $HOST_IP.

How do I get the current IP in a systemd service file?

Thanks!

submitted by DukeHarris
[link][5 comments]

Viewing all articles
Browse latest Browse all 17835

Trending Articles