{% set insecure_registries = [] %} {% for registry in [cicd_docker_registry, docker_registry_mirror] %} {% if registry|length > 0 %} {% do insecure_registries.append(registry) %} {% endif %} {% endfor %} { "insecure-registries": [ {%- for registry in insecure_registries %} "{{ registry }}"{% if not loop.last %}, {% else %}]{% endif %} {% endfor %} {% if docker_registry_mirror|length > 0 %} , "registry-mirrors": ["http://{{ docker_registry_mirror }}"] } {% else %} } {% endif %}