Scroll to top
© 2018 All Rights Reserved.

Setup Tor in a Docker Container

Dominik Sachsenhofer - 6. July 2018 - 1 comment

What is Tor?

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.


1. Setup

1.1 Create a Dockerfile:

This file is needed to create a docker image:

File: /Dockerfile

FROM alpine:latest
RUN apk update && apk add \
    tor \
    --update-cache --repository \
    && rm -rf /var/cache/apk/*
COPY torrc.default /etc/tor/torrc.default
RUN chown -R tor /etc/tor
USER tor
ENTRYPOINT [ "tor" ]
CMD [ "-f", "/etc/tor/torrc.default" ]


1.2 Create a torrc.default

File: /torrc.default

The only thing to change from the default torrc is the following line:



1.3 Build the Docker Image

Run the following command to build the docker image.

$ docker build -t sachsenhofer/tor_proxy .


1.4 Run the Docker Container

docker run -d \
--restart always \
-p 9050:9050 \
--name torproxy \


1.5 Test

Get your current ip

$ curl -L

Get your ip through the tor socks proxy

$ curl --socks5 http://localhost:9050 -L


2. Optional


Docker Image: sachsenhofer/tor_proxy

1 comment

  1. Anonymous

    Works great 🙂

Post a Comment