Skip to content

Commit

Permalink
Add proxy support for Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaser committed Jul 2, 2024
1 parent a81b17f commit 6327f72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions roles/docker/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ docker_cfg_dir: /etc/docker
docker_cfg_file: "{{ docker_cfg_dir }}/daemon.json"
docker_storage_dir: /var/lib/docker
docker_state_dir: /run/docker

docker_http_proxy: "{{ http_proxy | default('') }}"
docker_https_proxy: "{{ https_proxy | default('') }}"
docker_no_proxy: "{{ no_proxy | default('') }}"
4 changes: 2 additions & 2 deletions roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
state: present

- name: Create systemd service file for docker
ansible.builtin.copy:
src: docker.service
ansible.builtin.template:
src: docker.service.j2
dest: /etc/systemd/system/docker.service
mode: "0644"
notify:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ Type=notify
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
{% if docker_http_proxy %}
Environment="HTTP_PROXY={{ docker_http_proxy }}"
{% endif %}
{% if docker_https_proxy %}
Environment="HTTPS_PROXY={{ docker_https_proxy }}"
{% endif %}
{% if docker_no_proxy %}
Environment="NO_PROXY={{ docker_no_proxy }}"
{% endif %}
TimeoutStartSec=0
RestartSec=2
Restart=always
Expand Down

0 comments on commit 6327f72

Please sign in to comment.