A lightweight and secure Docker image for V2Ray v4 (specifically version v4.45.2, the final stable release of the 4.x branch). This image is built with security and minimalism in mind, utilizing a multi-stage Alpine build to minimize the container's attack surface.
v2ray (UID/GID configured) rather than root, greatly reducing container breakout risks.v2ray and the necessary v2ctl helper utility. Fully configured to use the classic -config parameter syntax.geoip.dat and geosite.dat routing assets in /usr/local/share/v2ray/.Create a configuration directory and save your config.json file.
Example path: /etc/v2ray/config.json
A minimal VLESS configuration template (config.json):
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"port": 10086,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "b831381d-6324-4d53-ad4f-8cda48b32611"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp"
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
For proxy tools, Host Network Mode (--network host) is highly recommended to bypass Docker's user-land proxy network translation, reducing CPU overhead and latency.
docker run -d \
--name v2ray-v4 \
--restart always \
--network host \
-v /etc/v2ray/config.json:/etc/v2ray/config.json:ro \
yourusername/v2ray:4.45.2-alpine
Note: Replace yourusername/v2ray:4.45.2-alpine with your actual pushed Docker Hub image tag.
If you prefer docker-compose, create a docker-compose.yml file in your working directory:
services:
v2ray:
image: yourusername/v2ray:4.45.2-alpine
container_name: v2ray-v4
restart: always
network_mode: "host" # Bypasses bridge translation to optimize speed & throughput
volumes:
- ./config.json:/etc/v2ray/config.json:ro # Mount as Read-Only for safety
command: ["-config", "/etc/v2ray/config.json"]
Run the container using:
docker compose up -d
/usr/local/bin/v2ray - Main executable/usr/local/bin/v2ctl - v4.x configuration control utility/usr/local/share/v2ray/ - Routing databases (geoip.dat, geosite.dat)/etc/v2ray/config.json - Default configuration file path (to be mounted)config.json with :ro (Read-Only) flag to prevent the containerized process from modifying its own setup if compromised.-p 80:10086) instead of running the container process as root.Content type
Image
Digest
sha256:304a2acc9…
Size
16.7 MB
Last updated
3 months ago
docker pull bilxio/v2ray:4-alpine