diff --git a/defaults/main.yml b/defaults/main.yml index afc9bf1..ec02ccf 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,4 +14,6 @@ docker_auth_config_homedir: /root docker_start_opts: - -H unix:///var/run/docker.sock +docker_registry_mirrors: [] + ... diff --git a/tasks/main.yml b/tasks/main.yml index 5d6527c..70722f9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -22,12 +22,18 @@ dest: /etc/systemd/system/docker.service.d/docker-startopts.conf register: docker_startopts +- name: Configure registry mirrors + copy: + content: '{"registry-mirrors": {{ docker_registry_mirrors | to_json }}}' + dest: /etc/docker/daemon.json + register: docker_mirrors + - name: Restart docker to apply new config systemd: name: docker.service state: restarted daemon_reload: yes - when: docker_startopts.changed + when: docker_startopts.changed or docker_mirrors.changed - name: Create docker configuration dir file: