diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index 707ccaf..82b3d54 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -12,3 +12,6 @@ LOG_MAX_FILE: 3 # docker容器存储目录 STORAGE_DIR: "/var/lib/docker" + +# 开启Restful API +ENABLE_REMOTE_API: false diff --git a/roles/docker/templates/daemon.json.j2 b/roles/docker/templates/daemon.json.j2 index a024bf7..ff627fb 100644 --- a/roles/docker/templates/daemon.json.j2 +++ b/roles/docker/templates/daemon.json.j2 @@ -8,4 +8,9 @@ "max-file": "{{ LOG_MAX_FILE }}" }, "data-root": "{{ STORAGE_DIR }}" + + {% if ENABLE_REMOTE_API %} + , "hosts": ["tcp://0.0.0.0:2376", "unix:///var/run/docker.sock"] + {% endif %} + }