Skip to content

Commit f221ab7

Browse files
committed
add fail2ban as example container for testing purposes
Signed-off-by: Simon L <[email protected]>
1 parent c320da2 commit f221ab7

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed

.github/workflows/json-validator.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ jobs:
2323
sudo apt-get install python3-pip -y --no-install-recommends
2424
sudo pip3 install json-spec
2525
json validate --schema-file=php/containers-schema.json --document-file=php/containers.json
26+
JSON_FILES="$(find ./community-containers -name '*.json')"
27+
mapfile -t JSON_FILES <<< "$JSON_FILES"
28+
for file in "${JSON_FILES[@]}"; do
29+
json validate --schema-file=php/containers-schema.json --document-file="$file" | tee -a ./json-validator.log
30+
done
31+
if grep "Exception: document does not validate with schema." ./json-validator.log; then
32+
exit 1
33+
fi
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"aio_services_v1": [
3+
{
4+
"container_name": "nextcloud-aio-fail2ban",
5+
"display_name": "Fail2ban",
6+
"image": "szaimen/aio-fail2ban",
7+
"image_tag": "%AIO_CHANNEL%",
8+
"internal_port": "host",
9+
"restart": "unless-stopped",
10+
"cap_add": [
11+
"NET_ADMIN",
12+
"NET_RAW"
13+
],
14+
"environment": [
15+
"TZ=%TIMEZONE%"
16+
],
17+
"volumes": [
18+
{
19+
"source": "nextcloud_aio_nextcloud",
20+
"destination": "/nextcloud",
21+
"writeable": false
22+
}
23+
]
24+
}
25+
]
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is not working on Docker Desktop since it needs network_mode: host in order to work correctly.

community-containers/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## This is a WIP and not working yet!

php/containers-schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"display_name": {
4141
"type": "string",
42-
"pattern": "^[A-Za-z ]+$"
42+
"pattern": "^[A-Za-z 0-9]+$"
4343
},
4444
"environment": {
4545
"type": "array",
@@ -51,7 +51,7 @@
5151
},
5252
"container_name": {
5353
"type": "string",
54-
"pattern": "^nextcloud-aio-[a-z-]+$"
54+
"pattern": "^nextcloud-aio-[a-z-0-9]+$"
5555
},
5656
"internal_port": {
5757
"type": "string",

php/src/Docker/DockerActionManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ public function CreateContainer(Container $container) : void {
477477
}
478478

479479
// Disable arp spoofing
480-
$requestBody['HostConfig']['CapDrop'] = ['NET_RAW'];
480+
if (!in_array('NET_RAW', $capAdds, true)) {
481+
$requestBody['HostConfig']['CapDrop'] = ['NET_RAW'];
482+
}
481483

482484
if ($container->isApparmorUnconfined()) {
483485
$requestBody['HostConfig']['SecurityOpt'] = ["apparmor:unconfined"];

0 commit comments

Comments
 (0)