Skip to content

Instantly share code, notes, and snippets.

@jceloria
Created May 21, 2018 19:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jceloria/84afa9304a1368cdd509f23f595a01fb to your computer and use it in GitHub Desktop.
Save jceloria/84afa9304a1368cdd509f23f595a01fb to your computer and use it in GitHub Desktop.
telegraf in Docker container
[Unit]
Description=telegraf in Docker container
After=docker.service container-influxdb.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop telegraf
ExecStartPre=-/usr/bin/docker rm telegraf
ExecStartPre=-/usr/bin/docker pull docker.io/telegraf:alpine
ExecStart=/usr/bin/docker run --rm -t \
-v /opt/data/telegraf/config:/etc/telegraf \
-v /opt/data/telegraf/scripts:/scripts \
--net=container:influxdb \
--name telegraf docker.io/telegraf:alpine
ExecStop=-/usr/bin/docker stop -t 3 telegraf
ExecStop=-/usr/bin/docker rm telegraf
Restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment