Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

mogeko/docker-trojan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-trojan

ci_icon image_size image_ver

Docker image for trojan.

  • Tiny size
  • Keep updating

Usage

Pull this image:

docker pull ghcr.io/mogeko/trojan

Run with docker cli:

docker run -d \
  --name trojan \
  -e ENVSUBST_ENABLED=true \
  -e TROJAN_LOCALE_ADDR=0.0.0.0 \
  -e TROJAN_LOCALE_PORT=443 \
  -e TROJAN_REMOTE_ADDR=127.0.0.1 \
  -e TROJAN_REMOTE_PORT=80 \
  -p 443:443 \
  -p 443:443/udp \
  -p 80:80 \
  -p 80:80/udp \
  -v /path/to/config:/config \
  -v /path/for/ssl/files:/config/ssl \
  --restart unless-stopped \
  ghcr.io/mogeko/trojan

Run with docker-compose:

---
version: 2.1
services:
  trojan:
    image: ghcr.io/mogeko/trojan
    container_name: trojan
    environment:
      - ENVSUBST_ENABLED=true
      - TROJAN_LOCALE_ADDR=0.0.0.0
      - TROJAN_LOCALE_PORT=443
      - TROJAN_REMOTE_ADDR=127.0.0.1
      - TROJAN_REMOTE_PORT=80
    volumes:
      - /path/to/config:/config
      - /path/for/ssl/files:/config/ssl
    ports:
      - 443:443
      - 443:443/udp
      - 80:80
      - 80:80/udp
    restart: unless-stopped

Parameters

We support the use of environment variables TROJAN_* to automatic settings configuration file1. You need to turn it on (default off) through environment variables ENVSUBST_ENABLE=true. When it is turned on, we will use the environment variable and template, automatically generate/config/config.json by envsubst. Original /config/config.json will be overwritten. Therefore, it CANNOT be compatible with manually set configuration files, and it may overwrite your profile. Click here to view the full list of TROJAN_*.

Although I recommend setting up a configuration file using environment variables2, we also support it manually. The path of the default configuration file is /config/config.json (in container). You can configure it according to your needs. By the way, if you don't want to use the default configuration file path, you can overwrite it by a parameter transmitted to trojan:

docker run [do something] ghcr.io/mogeko/trojan -c /path/to/config (in container)

To ensure that the container can run normally in the default state, the container randomly generates a set of SSL certificate.crt and private.key when it compiles. It works, BUT NOT SAFE! So you should prepare a set of your EXCLUSIVE SSL *.ctr and *.key, and override /config/ssl (or other path). Finally, you need to make sure your SSL files match the path being set in configuration file (by default, it's config/config.json).

More help message about trojan, you can get via:

docker run -it ghcr.io/mogeko/trojan --help

License

The code in this project is released under the GPL-3.0 License.

Footnotes

  1. Generate a configuration file from template by envsubst.

  2. WARNING: It may override your profile.

About

Docker image for trojan

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •