docker-compose.yaml support

This commit is contained in:
Paper-Dragon 2024-11-26 13:03:58 +08:00 committed by GitHub
parent 46bf4434ef
commit de50c1402a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -172,7 +172,8 @@ Currently, tun2proxy supports HTTP, SOCKS4/SOCKS4a and SOCKS5. A proxy is suppli
URL format. For example, an HTTP proxy at `1.2.3.4:3128` with a username of `john.doe` and a password of `secret` is URL format. For example, an HTTP proxy at `1.2.3.4:3128` with a username of `john.doe` and a password of `secret` is
supplied as `--proxy http://john.doe:secret@1.2.3.4:3128`. This works analogously to curl's `--proxy` argument. supplied as `--proxy http://john.doe:secret@1.2.3.4:3128`. This works analogously to curl's `--proxy` argument.
## Docker Support ## Container Support
### Docker
Tun2proxy can serve as a proxy for other Docker containers. To make use of that feature, first build the image: Tun2proxy can serve as a proxy for other Docker containers. To make use of that feature, first build the image:
```bash ```bash
@ -197,6 +198,36 @@ docker run -it \
--network "container:tun2proxy" \ --network "container:tun2proxy" \
ubuntu:latest ubuntu:latest
``` ```
### Docker Compose
The above docker command is written into a `docker-compose.yaml` file.
```yaml
services:
tun2proxy:
volumes:
- /dev/net/tun:/dev/net/tun
sysctls:
- net.ipv6.conf.default.disable_ipv6=0
cap_add:
- NET_ADMIN
container_name: tun2proxy
image: ghcr.io/tun2proxy/tun2proxy:latest
command: --proxy proto://[username[:password]@]host:port
alpine:
stdin_open: true
tty: true
network_mode: container:tun2proxy
image: alpine:latest
command: apk add curl && curl ifconfig.icu && sleep 10
```
run compose file
```bash
docker compose up -d tun2proxy
docker compose up alpine
```
## Configuration Tips ## Configuration Tips
### DNS ### DNS