xray-core built exactly from official source code, w/ documentation on how you can build it yourself
10K+
This is a proof of concept docker build for xray-core, to demonstrate how you can easily build it from source.
The chain of trust includes only:
xray-core source codeWhile there is the official docker build and some unofficial builds, blindly trusting any binaries can be potentially dangerous and life-threatening in suppressing regimes such as China, a risk perhaps you may not want to take.
You should NOT fully trust any unofficial builds, not even when the builder opensources their workflow, because how can anyone prove the provided builds are actually generated from the workflow, until one builds for themselves to reproduce it.
For the sake of the argument, you may not fully trust the official builds, either, unless the official builds have been consistently shown to be reproducible.
It is for these reasons that this documentation will be focusing on how you can build the xray-core docker on your own.
Note: For the same reasons, you should NOT trust my docker builds, either; instead, please read on and see how you can build one for yourself.
You need some basic understanding of git, docker and commandline, and if you are a frequent user of docker, it's probably not an issue.
This documentation is based on Linux, but the general ideas apply to macOS and Windows, too.
Clone the official xray-core git repo:
git clone https://github.com/XTLS/Xray-core.git
Open your terminal and enter the Xray-core directory:
cd Xray-core
Tell git which version you want to use, in this example, it'll be v1.8.13:
git checkout tags/v1.8.13
Build the docker with just 1 simple command, based on the Dockerfile inside ./github/docker:
docker build -t xray-core . -f .github/docker/Dockerfile
tip: you may need sudo permission; alternatively, you can manager docker as a non-sudo user.
That's it, the docker container is ready to use, and you can see the image by running:
docker images | grep xray
Let's assume the latest version is now 5.3.10, replace the Steps 1, 2 and 3 above with this:
cd Xray-core && git pull && git checkout tags/v5.3.10
Continue with Steps 4 and 5 above.
This may come handy when you want to build the docker once and deploy it elsewhere.
Only for the 1st time: visit docker hub and create an account.
Tip: user an email address that has nothing to do with your real-world life, such that even this account is compromised, it cannot be traced back to you. Use VPN / tor as well.
In your terminal, run:
docker login
enter your username and password
Re-tag your repo using this format: my_username/repo:
docker tag xray-core my_username/xray-core
Checking it for errors:
docker images | grep xray
If everything looks good, push it to dockerhub:
docker push my_username/xray-core
The docker container can now be used by any server when running:
docker run -d my_username/xray-core ...
or if you're using docker compose, your docker-compose.yaml file can look something like this:
version: '3.1'
services:
xray:
image: my_username/xray-core
container_name: xray-core
restart: unless-stopped
ports:
- 443:443
#environment:
# https://xtls.github.io/en/config/features/env.html
# XRAY_LOCATION_CONFDIR: /etc/xray/ # Enable multi-config mode
volumes:
- ./config_server.json:/etc/xray/config.json
- ./log/:/var/log/xray/
Note:
config_server.json, please refer to chika0801's collection of Xray-examples.log directory first, or the docker may not runContent type
Image
Digest
sha256:0e7e21839…
Size
18.4 MB
Last updated
about 2 years ago
docker pull fydq/xray-core