Skip to content

Instantly share code, notes, and snippets.

@rooty
Created May 9, 2026 13:38
Show Gist options
  • Select an option

  • Save rooty/921170df09ad59dfdd538afaa0f68e2c to your computer and use it in GitHub Desktop.

Select an option

Save rooty/921170df09ad59dfdd538afaa0f68e2c to your computer and use it in GitHub Desktop.
Заерытие порта docker service через systemd unit
# /etc/systemd/system/docker-iptables-rules.service
[Unit]
Description=Apply custom iptables rules for Docker
After=docker.service
Requires=docker.service
[Service]
Type=oneshot
ExecStart=/usr/sbin/iptables -C DOCKER-USER -p tcp --dport 5532 -j DROP || /usr/sbin/iptables -I DOCKER-USER -p tcp --dport 5532 -j DROP
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

iptables rules

sudo iptables -I DOCKER-USER -p tcp -s 127.0.0.1 --dport 5532 -j ACCEPT
sudo iptables -I DOCKER-USER -p tcp --dport 5532 -j DROP

Активируйте сервис:

sudo systemctl daemon-reload
sudo systemctl enable docker-iptables-rules.service
sudo systemctl start docker-iptables-rules.service

Теперь правило будет применяться при каждом запуске Docker/системы.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment