Browse Source

docker support

pull/66/head
PaperDragon-SH 3 years ago
committed by B. Blechschmidt
parent
commit
c0c7fda891
  1. 28
      Dockerfile
  2. 24
      README.md
  3. 29
      docker/entrypoint.sh

28
Dockerfile

@ -0,0 +1,28 @@
####################################################################################################
## Builder
####################################################################################################
FROM rust:latest AS builder
WORKDIR /worker
COPY ./ .
RUN cargo build --release --target x86_64-unknown-linux-gnu
####################################################################################################
## Final image
####################################################################################################
FROM ubuntu:latest
WORKDIR /app
ENV TUN=tun0
ENV PROXY=
ENV DNS=virtual
ENV MODE=auto
ENV BYPASS_IP=
RUN apt update && apt install -y iproute2 curl && apt clean all
COPY --from=builder /worker/target/x86_64-unknown-linux-gnu/release/tun2proxy /usr/bin/tun2proxy
COPY --from=builder /worker/docker/entrypoint.sh /app
ENTRYPOINT ["/app/entrypoint.sh"]

24
README.md

@ -108,6 +108,30 @@ 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
supplied as `--proxy http://john.doe:[email protected]:3128`. This works analogously to curl's `--proxy` argument.
## Docker Support
```bash
docker run -d \
-e PROXY=PROXY_TYPE://PROXY_IP:PROXY_PORT \
-v /dev/net/tun:/dev/net/tun \
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
--sysctl net.ipv6.conf.default.disable_ipv6=0 \
--cap-add NET_ADMIN \
--name tun2proxy \
image:tags
```
Provide a network to another worker container. (share netns).
```bash
docker run -it \
-d \
--network "container:tun2proxy" \
worker-example:tags
```
## Configuration Tips
### DNS
When DNS resolution is performed by a service on your machine or through a server in your local network, DNS resolution

29
docker/entrypoint.sh

@ -0,0 +1,29 @@
#!/bin/bash
run() {
if [ -n "$BYPASS_IP" ]; then
BYPASS_IP="--bypass-ip $BYPASS_IP"
fi
if [ -n "$DNS" ]; then
DNS="--dns $DNS"
fi
if [ -n "$MODE" ]; then
MODE="--setup $MODE"
fi
if [ -n "$PROXY" ]; then
PROXY="--proxy $PROXY"
fi
if [ -n "$TUN" ]; then
TUN="--tun $TUN"
fi
exec tun2proxy $TUN $PROXY $DNS $MODE $BYPASS_IP
}
run || echo "Runing ERROR!!"
Loading…
Cancel
Save