瀏覽代碼

harden docker-compose.yml (#760)

`user: nobody`: the least privileged account.
`read_only: true`: this container doesn't write anything to the filesystem, this removes a vector.
`security_opt`: disallows the container to grab more privileges.
`cap_drop`: this container doesn't need any capabilities, drop them.
`networks`: put `libreddit` into its own network so it cannot see other containers by default.
kuanhulio 2 年之前
父節點
當前提交
e25622dac2
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      docker-compose.yml

+ 11 - 0
docker-compose.yml

@@ -7,7 +7,18 @@ services:
     container_name: "libreddit"
     ports:
       - 8080:8080
+    user: nobody
+    read_only: true
+    security_opt:
+      - no-new-privileges:true
+    cap_drop:
+      - ALL
+    networks:
+      - libreddit
     healthcheck:
       test: ["CMD", "wget", "--spider", "-q", "--tries=1", "http://localhost:8080/settings"]
       interval: 5m
       timeout: 3s
+
+networks:
+  libreddit: