fix: harden container privileges

This commit is contained in:
lingkai5wu committed 2026-10-16 15:11:17 +08:00
1 parent abbcdb1a02
commit 6e02bd39ae
11 files changed
+51

No files matched your search

+2
View File
@@ -13,6 +13,8 @@ services:
networks: networks:
- proxy - proxy
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy: deploy:
resources: resources:
limits: limits:
+12
View File
@@ -20,6 +20,18 @@ services:
networks: networks:
- proxy - proxy
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
# Root keeps only the capabilities restic needs to read and restore
# files owned by other users.
cap_drop:
- ALL
cap_add:
- CHOWN
- DAC_OVERRIDE
- DAC_READ_SEARCH
- FOWNER
- FSETID
deploy: deploy:
resources: resources:
limits: limits:
+2
View File
@@ -68,6 +68,8 @@ docker_args=(
run run
--rm --rm
--network "container:$CONTAINER" --network "container:$CONTAINER"
--cap-drop ALL
--security-opt no-new-privileges:true
--cap-add NET_RAW --cap-add NET_RAW
--cap-add NET_ADMIN --cap-add NET_ADMIN
) )
+2
View File
@@ -7,6 +7,8 @@ services:
- /srv/data/ddns-go:/root - /srv/data/ddns-go:/root
network_mode: host network_mode: host
restart: always restart: always
security_opt:
- no-new-privileges:true
deploy: deploy:
resources: resources:
limits: limits:
+2
View File
@@ -13,6 +13,8 @@ services:
networks: networks:
- proxy - proxy
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy: deploy:
resources: resources:
limits: limits:
+2
View File
@@ -11,6 +11,8 @@ services:
TZ: Asia/Shanghai TZ: Asia/Shanghai
network_mode: host network_mode: host
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy: deploy:
resources: resources:
limits: limits:
+17
View File
@@ -21,6 +21,8 @@ services:
- default - default
- proxy - proxy
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
healthcheck: healthcheck:
disable: false disable: false
deploy: deploy:
@@ -41,6 +43,10 @@ services:
env_file: env_file:
- .env - .env
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
healthcheck: healthcheck:
disable: false disable: false
deploy: deploy:
@@ -61,6 +67,8 @@ services:
ports: ports:
- "127.0.0.1:5432:5432" - "127.0.0.1:5432:5432"
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
healthcheck: healthcheck:
disable: false disable: false
deploy: deploy:
@@ -76,6 +84,15 @@ services:
image: docker.io/valkey/valkey:9@sha256:c123e3715db63d06d4ad6964884037aa0d5d4d703939b9929954112889708e1d image: docker.io/valkey/valkey:9@sha256:c123e3715db63d06d4ad6964884037aa0d5d4d703939b9929954112889708e1d
container_name: immich-redis container_name: immich-redis
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
# The official image starts as root and drops to the valkey user.
cap_drop:
- ALL
cap_add:
- CHOWN
- SETGID
- SETUID
healthcheck: healthcheck:
test: redis-cli ping || exit 1 test: redis-cli ping || exit 1
deploy: deploy:
+4
View File
@@ -24,6 +24,8 @@ services:
extra_hosts: extra_hosts:
- "host.internal:172.31.255.1" - "host.internal:172.31.255.1"
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy: deploy:
resources: resources:
limits: limits:
@@ -44,6 +46,8 @@ services:
CF_Zone_ID: ${CF_ZONE_ID} CF_Zone_ID: ${CF_ZONE_ID}
command: daemon command: daemon
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy: deploy:
resources: resources:
limits: limits:
+4
View File
@@ -13,6 +13,10 @@ services:
networks: networks:
- proxy - proxy
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
user: 1000:1000 user: 1000:1000
deploy: deploy:
resources: resources:
+2
View File
@@ -19,6 +19,8 @@ services:
networks: networks:
- proxy - proxy
restart: unless-stopped restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy: deploy:
resources: resources:
limits: limits:
+2
View File
@@ -13,6 +13,8 @@ services:
ports: ports:
- "192.168.10.101:445:445" - "192.168.10.101:445:445"
restart: always restart: always
security_opt:
- no-new-privileges:true
deploy: deploy:
resources: resources:
limits: limits: