diff --git a/README.md b/README.md index ec1b517..74ff2ed 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,7 @@ This will create: * `container_image` (**required**) - Docker image the service uses * `container_args` - arbitrary list of arguments to the `docker run` command as a string -* `container_cmd` - optional command to the container run command (the part after the - image name) +* `container_cmd` (default: _[]_) - optional list of commands to the container run command (the part after the image name) * `container_env` - key/value pairs of ENV vars that need to be present * `container_volumes` (default: _[]_) - List of `-v` arguments * `container_host_network` (default: _false_) - Whether the host network should be used diff --git a/defaults/main.yml b/defaults/main.yml index 6366811..1909c38 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,6 +2,7 @@ container_name: "{{ name }}" container_docker_pull: true container_labels: [] +container_cmd: [] container_host_network: false container_network: "" container_links: [] diff --git a/templates/unit.j2 b/templates/unit.j2 index aee5f9d..9387095 100644 --- a/templates/unit.j2 +++ b/templates/unit.j2 @@ -35,7 +35,7 @@ ExecStart={{ docker_path }} run \ {{ params('--device', container_devices) }}\ {% if container_privileged == true %}--privileged{% endif %}\ {{ container_args | trim }} \ - {{ container_image }} {{ container_cmd | default('') | trim }} + {{ container_image }} {% if container_cmd is string %}{{ container_cmd | trim }}{% else %}{{ container_cmd | join(' ') | trim }}{% endif %} {% endif %} {% if not 'ExecStop' in service_systemd_options_keys %} ExecStop={{ docker_path }} stop {{ container_name }}