blob: cf1e2de72a99eec2b14350afd0879a6b52c83d67 [file] [log] [blame]
[Unit]
Description=Docker container for {{ name }}
Requires=docker.service
After=docker.service
{#- Ugly, but covers the cases where variable evaluates to false, is empty, or non-existent #}
{%- set runoptions = container.get("runoptions") or [] %}
{%- set stopoptions = container.get("stopoptions") or [] %}
{%- set cmd = container.get("cmd") or "" %}
{%- if runoptions == "None" %}
{%- set runoptions = [] %}
{%- endif %}
{%- if cmd == "None" %}
{%- set cmd = "" %}
{%- endif %}
[Service]
Restart=always
ExecStart=/usr/bin/docker run -d {% for option in runoptions %}{{ option }} {% endfor %} --name={{ name }} {{ container.image }} {{ cmd }}
ExecStop=/usr/bin/docker stop {{ name }}
ExecStopPost=/usr/bin/docker rm -f {{ name }}
[Install]
WantedBy=local.target