1. 安装docker
systemctl stop firewalld
setenforce 0
yum install -Y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce lrzsz
systemctl start docker
2 、下载镜像
docker pull kylemanna/openvpn
3、启动服务
OVPN_DATA="ovpn-data"
VPN_USER="aaa"
IP="10.10.10.10"
PORT="18000"
docker volume create --name $OVPN_DATA
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://$IP
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
docker run -v $OVPN_DATA:/etc/openvpn -d -p ${PORT}:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full ${VPN_USER} nopass
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient ${VPN_USER} > ${VPN_USER}.ovpn