# Running a Tor relay with Docker

DevFeed: [Running a Tor relay with Docker](<https://devfeed.tech/articles/running-a-tor-relay-with-docker-35192.md>)

Original publisher: [Read original article](<https://blog.jessfraz.com/post/running-a-tor-relay-with-docker/>)

Published: 2015-08-23T16:02:01Z

Content type: tutorial

Language: en

Sources: [Jessie Frazelle](<https://devfeed.tech/sources/jessie-frazelle.md>)

Topics: [Docker](<https://devfeed.tech/topics/docker.md>), [Dockerfile](<https://devfeed.tech/topics/dockerfile.md>), [container](<https://devfeed.tech/topics/container.md>), [Docker Container](<https://devfeed.tech/topics/docker-container.md>), [Docker Image](<https://devfeed.tech/topics/docker-image.md>), [hosting](<https://devfeed.tech/topics/hosting.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Network](<https://devfeed.tech/topics/network.md>)

Tags: [bridge](<https://devfeed.tech/tags/bridge.md>), [docker](<https://devfeed.tech/tags/docker.md>), [docker-container](<https://devfeed.tech/tags/docker-container.md>), [docker-image](<https://devfeed.tech/tags/docker-image.md>), [exit-node](<https://devfeed.tech/tags/exit-node.md>), [hosting](<https://devfeed.tech/tags/hosting.md>), [linux](<https://devfeed.tech/tags/linux.md>), [network](<https://devfeed.tech/tags/network.md>), [tor](<https://devfeed.tech/tags/tor.md>)

## AI overview

A tutorial on running Tor bridge, middle, and exit relays in Docker containers. It covers creating a minimal Alpine-based Docker image with separate Tor configurations, running each relay type, and checking whether an exit node has registered.

## Source excerpt

This post is part two of what will be a three part series. If you missed it part one was How to Route Traffic through a Tor Docker container. I figured it was important, if you are going to be a tor user, to document how you can help the Tor community by hosting a Tor relay. And guess what? You can use Docker to do this! There are three types of relays you can host, a bridge relay, a middle relay, and an exit relay. Exit relays tend to be the ones recieving take down notices because the IP is the one the public sees traffic from Tor as. A great reference for hosting an exit node can be found here blog.torproject.org/blog/tips-running-exit-node-minimal-harassment. But I will go over how to host each from a Docker container. My example will have a reduced exit policy and limit which ports you are willing to route traffic through. If you don't want to host an exit node, host a middle relay instead! And if you want your relay not publically listed in the network then host a bridge. Creating the base image I have created a Docker image jess/tor-relay from this Dockerfile. Feel free to create your own image with the following Dockerfile: FROM alpine:latest # Note: Tor is only in testing repo RUN apk update && apk add \ tor \ --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ \ && rm -rf /var/cache/apk/* # default port to used for incoming Tor connections # can be changed by changing 'ORPort' in torrc EXPOSE 9001 # copy in our torrc files COPY torrc.bridge /etc/tor/torrc.bridge COPY torrc.middle /etc/tor/torrc.middle COPY torrc.exit /etc/tor/torrc.exit # make sure files are owned by tor user RUN chown -R tor /etc/tor USER tor ENTRYPOINT [ "tor" ] As you can see we are copying 3 different torrc's into the container. One for each a bridge, middle, and exit relay. I used alpine linux because it is super minimal. The size of the image is 11.52MB! Crazyyyyyyy! Running a bridge relay A bridge relay is not publically listed as part of the Tor network. Th