Skip to content

Running in docker doesnt allow to reload tor for ip change #5

Open

Description

@dmitrisky

Hey,

Trying to run tornet in docker compose, and whenever trying to change IP, experience this error:

systemctl reload tor

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to system scope bus via local transport: Host is down

Versions:

cat /etc/debian_version
13.5

docker --version
Docker version 29.5.2, build 79eb04c

tornet --version
tornet 2.0.2

Dockerfile:

FROM python:3.14

RUN apt-get update && apt-get upgrade -y && apt-get install -y tor
RUN pip install --no-cache-dir tornet

# CRITICAL: by default Tor binds SOCKS to 127.0.0.1, which is unreachable
# from another container. Bind it to all interfaces instead.
RUN echo "SocksPort 0.0.0.0:9050" >> /etc/tor/torrc

EXPOSE 9050

CMD ["tornet", "--interval", "60", "--count", "0"]

Let me know if you need more details or there any other workaround. Thanks and appreciate great app!

Activity

  1. dmitrisky commented on May 25, 2026

    @dmitrisky
    Author

    For containers, following command might be used to reload tor:

    killall -HUP tor
  2. mrfidal commented on Jun 12, 2026

    @mrfidal

    Thanks for reporting this and for including the details.

    You're correct — inside most Docker containers, systemd is not running as PID 1, so systemctl reload tor will fail. In containerized environments, sending a HUP signal directly to the Tor process is the appropriate way to request a configuration reload and circuit rotation:

    killall -HUP tor

    I'll update tornet to detect container environments and fall back to signaling the Tor process instead of relying solely on systemctl.

    As a temporary workaround, using killall -HUP tor (or pkill -HUP tor) should allow IP rotation to work inside Docker containers.

    Thanks for identifying this edge case and for suggesting the fix.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions