[Unit]
Description=kontena-agent
After=network-online.target
After=docker.service
Description=Kontena Agent
Documentation=http://www.kontena.io/
Requires=network-online.target
Requires=docker.service

[Service]
Restart=always
RestartSec=5
EnvironmentFile=/etc/kontena-agent.env
ExecStartPre=-/usr/bin/docker stop kontena-agent
ExecStartPre=-/usr/bin/docker rm kontena-agent
ExecStart=/usr/bin/docker run --name kontena-agent \
    --env-file /etc/kontena-agent.env \
    -v=/var/run/docker.sock:/var/run/docker.sock \
    --net=host \
    kontena/agent:${KONTENA_VERSION}
ExecStartPost=/opt/kontena/kontena-resolvconf.sh start
ExecStop=/usr/bin/docker stop kontena-agent

[Install]
WantedBy=multi-user.target
