havenodex/tor

By havenodex

Updated almost 2 years ago

A dockerized version of Tor catered to the user of Haveno.

Image
Networking
Security
Developer tools
1

1.2K

havenodex/tor repository overview

Docker Tor: Getting Started

Docker Tor provides an easy way to build and run the Tor daemon from source inside a Docker container. This guide covers using the Docker image, configuration options, running with docker compose and building from source with the included Makefile.

This was originally intended for use for the Haveno project stack however, it can be used by anyone to simplify your experience with Tor.

What is Tor?

Tor (The Onion Router) is free and open-source software for enabling anonymous communication. It routes internet traffic through a volunteer overlay network to conceal a user's location and usage from network surveillance or traffic analysis. Tor is commonly used for privacy and protection against online tracking.

Table of Contents

  1. Running with Docker
  2. Using Docker Compose
  3. Environment Variables
  4. Building from Source with Makefile
  5. Makefile Options
  6. Additional Information

Running with Docker

To run the Tor Docker image with docker run, use the following command:

docker run -i -d --rm \
  -p 9050:9050 \
  havenodex/tor
  • -p 9050:9050: Maps port 9050 on the container (Tor's default SOCKS5 proxy port) to port 9050 on the host.
  • -i -d --rm: Runs the container in the background (-d), keeps it running interactively (-i), and automatically removes it when stopped (--rm).

You can also use Docker Compose to run the Tor container. Here’s an example docker-compose.yml file:

version: '3.8'

services:
  tor:
    image: havenodex/tor
    environment:
      - TOR_PROXY=true
      - TOR_PROXY_PORT=9050
      - TOR_CONTROL_PORT=9051
      - TOR_SERVICE=false
    ports:
      - "9050:9050"
      - "9051:9051"
  • image: Specifies the Docker image to use.
  • container_name: Names the container.
  • environment: Configures environment variables (discussed below).
  • ports: Maps ports on the host to the container.

Run the container using Docker Compose:

docker-compose up -d

Environment Variables

The following environment variables can be used to configure the Tor container:

VariableDefault ValueDescription
TOR_PROXYtrueEnables the Tor SOCKS5 proxy.
TOR_PROXY_PORT9050The port for the SOCKS5 proxy.
TOR_CONTROLfalseEnables the Tor control port.
TOR_CONTROL_PORT9051The port for the Tor control interface.
TOR_SERVICEfalseEnables hidden service hosting.
TOR_SERVICE_HOSTSN/AComma-separated list of services to expose via Tor.
TOR_RELAYfalseEnables relay mode to route traffic through the Tor network.
DATA_DIR/torDirectory for Tor data storage.
PUIDN/AUser ID to run the Tor service.
PGIDN/AGroup ID to run the Tor service.
TOR_LOG_CONFIGfalseIf true, logs the Tor configuration.

You can set these variables using the -e flag in docker run or in the environment section of the docker-compose.yml file.

Building from Source with Makefile

To build the Docker image from source, clone the repository and use the provided Makefile. Ensure Docker is installed and set up for multi-platform builds.

Building the Image Without GPL Features

To build the image without GPL features, run:

make build-nogpl
Building the Image with GPL Features

To build the image with GPL features, which include the Proof-of-Work mechanism enabled, run:

make build
Tagging the Image as Latest

To tag the image as latest, use the LATEST flag:

make build LATEST=true

Makefile Options

The Makefile includes several commands for building, running, and managing the Docker container:

CommandDescription
make loginLog in to Docker.
make list-buildersList available Docker buildx builders.
make initialise-builderInitialize a new Docker buildx builder.
make build-nogplBuild the Docker image without GPL features.
make buildBuild the Docker image with GPL features.
make build LATEST=trueBuild the Docker image and tag it as latest.
make build-docsBuild the documentation using MkDocs.
make runRun the Docker container.
make run-armRun the Docker container on ARM architecture.
make stopStop the running Docker container.
make inspectInspect the latest Docker image using Buildx.
make test-install-linuxInstall container-structure-test on Linux.
make test-install-osxInstall container-structure-test on macOS.
make testRun container structure tests.

Additional Information

This Docker image extends the capabilities of Tor by allowing easy source builds with configurable options, making it suitable for various use cases, including running as a proxy, relay, or hidden service.

For more details about Tor and its configuration options, visit the Kewbit.org and you can find the official documentation on The Tor Project website.

Tag summary

Content type

Image

Digest

sha256:1ec6f07bf

Size

1.1 GB

Last updated

almost 2 years ago

docker pull havenodex/tor