Docker tun device into container install openvpn or other soft, which uses tun devices
-
-
Save arcturus011/ec190e11f2e5d8b528c764de47ebe4cf to your computer and use it in GitHub Desktop.
docker tun device into container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
rsync_server: | |
container_name: openvpn | |
image: 'myopenvpn' | |
environment: | |
TZ: "Asia/Shanghai" | |
cap_add: | |
- NET_ADMIN | |
restart: always | |
devices: | |
- "/dev/net/tun" | |
volumes: | |
- $PWD/pi3.ovpn:/etc/openvpn/openvpn.conf | |
- $PWD/start_vpn.sh:/bin/start_vpn.sh | |
command: > | |
bash -c "echo '开始 openvpn'; | |
iptables -o eth0 -t nat -I POSTROUTING -j MASQUERADE; | |
openvpn --config /etc/openvpn/openvpn.conf" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -d --name tundevica \ | |
--cap-add=NET_ADMIN \ | |
--device /dev/net/tun \ | |
ubuntu tail -f /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment