Skip to content

Instantly share code, notes, and snippets.

@magicstone1412
Created October 27, 2024 01:38
Show Gist options
  • Save magicstone1412/85e5d6ed5a237fce926876bce7ed65e2 to your computer and use it in GitHub Desktop.
Save magicstone1412/85e5d6ed5a237fce926876bce7ed65e2 to your computer and use it in GitHub Desktop.
Tor proxy using Docker
# Set the latest version of Alpine Linux as the base image
FROM alpine:latest
# Updates the package list in the Alpine package manager and installs the Tor package.
RUN apk update && apk add tor
# Instructs Tor to send log notices to the standard output
RUN echo "Log notice stdout" >> /etc/torrc
# Configures Tor to listen for SOCKS connections on all network interfaces (0.0.0.0) on port 9050
RUN echo "SocksPort 0.0.0.0:9050" >> /etc/torrc
# expose port
EXPOSE 9050
# Set the default container command, Starts the Tor service using the specified configuration file
CMD ["tor", "-f", "/etc/torrc"]
@magicstone1412
Copy link
Author

magicstone1412 commented Oct 27, 2024

Build

docker build -t skywirex/tor .

Run

docker run -d     --rm   --name tor      -p 9050:9050   skywirex/tor

Check

curl --socks5 127.0.0.1:9050 https://check.torproject.org/api/ip

Compose

---
services:
  tor-proxy:
    image: skywirex/tor:latest
    container_name: tor
    ports:
      - 9050:9050
    restart: on-failure:5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment