Skip to content

Commit 2bbeecc

Browse files
committed
[ansible] Set global ulimits in daemon.json for AWS compatibility
Increase nofile to 65536 and memlock to -1 globally to prevent service exhaustion in restrictive environments like AWS EC2. Signed-off-by: Quan Zhou <quan@bitergia.com>
1 parent c9c45e4 commit 2bbeecc

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"default-ulimits": {
3+
"nofile": {
4+
"Name": "nofile",
5+
"Hard": 65536,
6+
"Soft": 65536
7+
},
8+
"memlock": {
9+
"Name": "memlock",
10+
"Hard": -1,
11+
"Soft": -1
12+
}
13+
}
14+
}

ansible/roles/common/tasks/docker.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,24 @@
4242
name: "{{ ansible_user_id }}"
4343
groups: docker
4444
append: true
45+
46+
- name: Ensure Docker configuration directory exists
47+
file:
48+
path: /etc/docker
49+
state: directory
50+
mode: '0755'
51+
52+
- name: Apply default ulimits configuration
53+
copy:
54+
src: "{{ role_path }}/files/daemon.json"
55+
dest: /etc/docker/daemon.json
56+
mode: '0644'
57+
register: docker_config
58+
59+
- name: Restart Docker to apply changes
60+
become: yes
61+
systemd_service:
62+
name: docker
63+
state: restarted
64+
daemon_reload: yes
65+
when: docker_config.changed

0 commit comments

Comments
 (0)