Skip to content

Commit 3398ca4

Browse files
authored
Update entrypoint.sh
1 parent 89aae2a commit 3398ca4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

entrypoint.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
set -euo pipefail
44
c=$'\n\t'
55

6+
# since alpine version 3.19.0 iptables-nft is used by default (https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.19.0),
7+
# however this causes compatibility issues for hosts with older kernels (e.g. Windows > https://github.com/microsoft/WSL/issues/6044),
8+
# therefore we still use iptables-legacy
9+
alias iptables=iptables-legacy
10+
611
# --- Ensure container network capabilities ----------------------------------
712

813
if ! capsh --has-p='cap_net_admin' --has-p='cap_net_raw' &>/dev/null
@@ -82,20 +87,20 @@ do
8287
# nft add rule nat prerouting tcp \
8388
# dport "${docker_container_port}" \
8489
# dnat to "$docker_host_ip:$docker_host_port"
85-
iptables-legacy --table nat --insert PREROUTING \
90+
iptables --table nat --insert PREROUTING \
8691
--protocol tcp --destination-port "${docker_container_port/-/:}" \
8792
--jump DNAT --to-destination "$docker_host_ip:$docker_host_port"
8893

8994
# nft add rule nat prerouting udp \
9095
# dport "${docker_container_port}" \
9196
# dnat to "$docker_host_ip:$docker_host_port"
92-
iptables-legacy --table nat --insert PREROUTING \
97+
iptables --table nat --insert PREROUTING \
9398
--protocol udp --destination-port "${docker_container_port/-/:}" \
9499
--jump DNAT --to-destination "$docker_host_ip:$docker_host_port"
95100
done
96101

97102
# nft add rule nat postrouting masquerade
98-
iptables-legacy --table nat --insert POSTROUTING --jump MASQUERADE
103+
iptables --table nat --insert POSTROUTING --jump MASQUERADE
99104

100105

101106
# --- Drop root access and "Ah, ha, ha, ha, stayin' alive" ---------------------

0 commit comments

Comments
 (0)