Scroll to top
© 2018 All Rights Reserved.
Share

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 http://dl-3.alpinelinux.org/alpine/edge/testing/ \
    && rm -rf /var/cache/apk/*
EXPOSE 9050
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:

SocksPort 0.0.0.0:9050

 

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 \
sachsenhofer/tor_proxy

 

1.5 Test

Get your current ip

$ curl -L http://ifconfig.me

Get your ip through the tor socks proxy

$ curl --socks5 http://localhost:9050 -L http://ifconfig.me

 

2. Optional

GitHub: https://github.com/sachsenhofer/tor_proxy

Docker Image: sachsenhofer/tor_proxy

1 comment

  1. Anonymous

    Works great 🙂

Post a Comment