NowTunnel For Docker 安装配置

nowtunnel介绍

nowtunnel是一款隧道工具,通过中继服务转发实现多个软件终端互联互通;支持软件、虚拟机、硬件等方式部署;端口转发、内网穿透、代理转发等能力。

Docker环境

CentOS

# 安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
# 源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
# 安装最新稳定版本的docker
yum install docker-ce

# 开启内核转发功能
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
sysctl -p

Ubuntu

sudo apt remove docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc
sudo apt install ca-certificates curl gnupg lsb-release
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
    "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
    $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
    sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# 开启内核转发功能
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
sysctl -p

Dockerfile 构建(基于Alpine-3.19实现完整nowtunnel功能)

Dockerfile

FROM alpine:3.19
ARG ARCH

RUN apk update && apk add --no-cache ca-certificates wireguard-tools iptables iptables-legacy iproute2 wget vim iputils && rm -rf /var/cache/apk/*

RUN wget -qO- https://download.nowtunnel.com/nowtunnel-linux-${ARCH}.tar.gz | tar -xz -C /usr/local/ && \
chmod +x /usr/local/nowtunnel/nowtunnel && \
chmod +x /usr/local/nowtunnel/nowtunnel-bash.sh && \
chmod 755 /usr/local/nowtunnel/cache && \
chmod 755 /usr/local/nowtunnel/log

RUN echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
RUN echo "net.ipv6.conf.all.forwarding = 1" >> /etc/sysctl.conf

WORKDIR /app

CMD ["/bin/bash", "/usr/local/nowtunnel/nowtunnel-bash.sh"]

Build

# Build
docker build --build-arg ARCH=x86_64 -t alpine-3.19:nowtunnel .
#docker build --build-arg ARCH=aarch64 -t alpine-3.19:nowtunnel .

# Run
docker run --net bridge --privileged --restart=always -itd -p 9601:9501 --hostname mynowtunnel --name mynowtunnel alpine-3.19:nowtunnel /usr/local/nowtunnel/nowtunnel-bash.sh

# Docker 运行日志
docker logs mynowtunnel

# Web control
http://宿主IP:9601
# 看到以下内容,证明已经成功运行
# NowTunnel starting. [DATE:2023-12-29 13:44:39, VER:2.1.10, LST:0.0.0.0:9501, INS: ]

posted on 2024-05-15 16:23  jasonss  阅读(24)  评论(0编辑  收藏  举报