Small docker of Tor client

Óscar García Amor 59322477d7 Simplifies build and adds multiarch support 5 months ago
.circleci 59322477d7 Simplifies build and adds multiarch support 5 months ago
Dockerfile 6179a88026 Migrated to CircleCI 3 years ago
LICENSE 8f3e84a23b Initial commit 7 years ago
Makefile 59322477d7 Simplifies build and adds multiarch support 5 months ago
README.md 28738e5f69 [skip ci] Fixes Quay URL 6 months ago

README.md

Small container of Tor client CircleCI

(c) 2015-2023 Óscar García Amor

Redistribution, modifications and pull requests are welcomed under the terms of GPLv3 license.

Tor is free software and an open network that helps you defend against traffic analysis, a form of network surveillance that threatens personal freedom and privacy, confidential business activities and relationships, and state security.

This container packages Tor under Alpine Linux, a lightweight Linux distribution.

Visit Quay or GitHub to see all available tags.

Run

To run this container, simply exec.

docker run -d \
  --name=tor \
  -v /srv/tor/cfg:/etc/tor \
  -v /srv/tor/data:/var/lib/tor \
  ghcr.io/connectical/tor

This start tor client and store config in /srv/tor/cfg and data in /srv/tor/data persistent volumes.

Take note that, by default, tor store its data into /var/lib/tor as a home directory, you need to add the following line in torrc config file to set as data directory and set owner of /srv/tor/data to UID and GID 100.

mkdir -p /srv/tor/cfg /srv/tor/data
echo "DataDirectory /var/lib/tor" > /srv/tor/cfg/torrc
chown 100:100 /srv/tor/data

Sample configs

Tor SOCKS Proxy

To use as Tor proxy set /srv/tor/cfg/torrc as following.

SOCKSPort 0.0.0.0:9050
DataDirectory /var/lib/tor

And run it.

docker run -d \
  --name=tor \
  -p 127.0.0.1:9050:9050 \
  -v /srv/tor/cfg:/etc/tor \
  -v /srv/tor/data:/var/lib/tor \
  ghcr.io/connectical/tor

Next, open your browser, set 127.0.0.1:9050 as socks proxy and go to https://check.torproject.org/ to check if you are using the Tor network.

Tor Hidden Service

To use as service server.

SOCKSPort 0
DataDirectory /var/lib/tor
HiddenServiceDir /var/lib/tor/github.com/
HiddenServicePort 22  192.30.253.112:22
HiddenServicePort 80  192.30.253.112:80
HiddenServicePort 443 192.30.253.112:443

And run it.

docker run -d \
  --name=tor \
  -v /srv/tor/cfg:/etc/tor \
  -v /srv/tor/data:/var/lib/tor \
  ghcr.io/connectical/tor

Other

You can use tor as bridge, enter relay or exit relay, see Tor Docs for more info.

Shell run

If you can run a shell instead tor command, simply do.

docker run -t -i --rm \
  --name=tor \
  -v /srv/tor/cfg:/etc/tor \
  -v /srv/tor/data:/var/lib/tor \
  --entrypoint=/bin/sh \
  ghcr.io/connectical/tor

Please note that the --rm modifier destroy the container after shell exit.

See tor sample config

If you need to see a documented config file of tor, you can open the torrc.sample with following command.

docker run -t -i --rm --entrypoint=/usr/bin/less \
  ghcr.io/connectical/tor /etc/tor/torrc.sample