VPS Networking Tutorial

How to Run V2Ray
on a VPS and Connect from Android

This guide explains a simple educational setup for running V2Ray on a Linux VPS with Docker and connecting from an Android phone using a V2Ray-compatible client such as v2rayNG.

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.

Step 01

Prepare VPS

Use a Linux VPS with Docker and an open TCP port.

Step 02

Generate Config

Create a UUID and V2Ray server config with Python.

Step 03

Run Docker

Start the V2Ray container using Docker Compose.

Step 04

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

clone repository
git clone https://github.com/farshidghaffari/v2ray-vps-mobile-setup.git
cd v2ray-vps-mobile-setup

2. Generate the server configuration

The repository includes a small Python script that generates a UUID and creates the V2Ray server configuration file.

generate config
python3 scripts/generate_config.py

This command creates:

  • config/config.json
  • client-info.txt

3. Start V2Ray with Docker Compose

start server
docker compose up -d

4. Check the logs

check logs
docker compose logs -f

Docker Compose file

The project uses a compact Docker Compose file to run the V2Ray container and mount the generated configuration file.

docker-compose.yml
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:

ufw firewall
sudo ufw allow 10086/tcp
sudo ufw reload

If 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

common commands
docker compose ps
docker compose restart
docker compose down
docker compose pull
docker compose up -d

Related GitHub repository

The complete project files are available in the GitHub repository below.