Use this guide only for lawful privacy, security, and personal networking purposes. Follow the laws and terms of service that apply in your country, VPS provider, and network.
What this tutorial covers
In this tutorial, we will set up a beginner-friendly V2Ray server on a VPS using Docker. The setup uses a simple VMess TCP configuration, a generated UUID, and a Docker Compose file.
The goal is to keep the server structure clean, repeatable, and easy to understand. The related GitHub repository includes the full project files and documentation.
Prepare VPS
Use a Linux VPS with Docker and an open TCP port.
Generate Config
Create a UUID and V2Ray server config with Python.
Run Docker
Start the V2Ray container using Docker Compose.
Connect Android
Use v2rayNG or another compatible Android client.
Requirements
- A Linux VPS
- Docker installed on the server
- Docker Compose plugin
- An open TCP port, default: 10086
- An Android phone with a V2Ray-compatible client
Quick start
1. Clone the repository
git clone https://github.com/farshidghaffari/v2ray-vps-mobile-setup.git
cd v2ray-vps-mobile-setup2. Generate the server configuration
The repository includes a small Python script that generates a UUID and creates the V2Ray server configuration file.
python3 scripts/generate_config.pyThis command creates:
- config/config.json
- client-info.txt
3. Start V2Ray with Docker Compose
docker compose up -d4. Check the logs
docker compose logs -fDocker Compose file
The project uses a compact Docker Compose file to run the V2Ray container and mount the generated configuration file.
services:
v2ray:
image: v2fly/v2fly-core:latest
container_name: v2ray
restart: unless-stopped
command: run -c /etc/v2ray/config.json
volumes:
- ./config/config.json:/etc/v2ray/config.json:ro
ports:
- "10086:10086/tcp"Open the firewall port
If your server uses UFW, allow the selected TCP port:
sudo ufw allow 10086/tcp
sudo ufw reloadIf your VPS provider has a separate cloud firewall, you must also allow TCP port 10086 there.
Android setup with v2rayNG
On Android, create a new VMess profile and enter the values from client-info.txt.
- Address: your VPS IP address
- Port: 10086
- User ID / UUID: the generated UUID
- Alter ID: 0
- Security: auto
- Network: tcp
Troubleshooting checklist
- Check that Docker is running.
- Check that config/config.json exists.
- Check that the UUID is copied correctly.
- Check that TCP port 10086 is open.
- Check server logs with docker compose logs -f.
- Check your VPS provider firewall settings.
Useful commands
docker compose ps
docker compose restart
docker compose down
docker compose pull
docker compose up -dRelated GitHub repository
The complete project files are available in the GitHub repository below.