Skip to content

Commit

Permalink
Fix container systemd template
Browse files Browse the repository at this point in the history
  • Loading branch information
medanthelinium committed Nov 12, 2024
1 parent 4f75d87 commit fb14d40
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions templates/systemd/container.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
[Unit]
Requires=docker.service
After=docker.service
{%- for dependency in container.depends_on | default([]) %}
Wants={{ dependency }}.service
{%- endfor %}

{%- endmacro %}

{% macro volume_options(volume) -%}
Expand Down Expand Up @@ -34,7 +38,7 @@ Restart=always
RestartSec=10
TimeoutStopSec=60
{% if container.pull_on_start|default(false) -%}
ExecStartPre=-docker pull {{ container.image|quote }}
ExecStartPre=docker pull {{ container.image|quote }}
{% endif -%}
ExecStartPre=bash -c "{ docker stop --time=50 {{ container.container_name }} && docker rm {{ container.container_name }}; } || :"
{%- for volume in (container.volumes|default({})).values()|selectattr('host_dir', 'string')|selectattr('owner', 'number') %}
Expand All @@ -56,9 +60,6 @@ ExecStartPre=docker create --name={{ container.container_name }} --rm \
{%- if container.entrypoint|default(none) %}
--entrypoint={{ container.entrypoint|quote }} \
{%- endif %}
{%- for dependency in container.depends_on | default([]) %}
Wants={{ dependency }}.service
{%- endfor %}
{{ container.image|quote }}{{ '' if not container.command|default(none) or container.command.items()|rejectattr('1', 'eq', none)|first|default(none) is none else ' \\' }}
{%- for _, argument in (container.command.items()|rejectattr('1', 'eq', none) if container.command|default(none) else []) %}
{{ argument|quote }}{% if not loop.last %} \{%- endif %}
Expand Down

0 comments on commit fb14d40

Please sign in to comment.