I found that the Tails has been evaluating Docker. However, I'd like to have a Docker image that connects only through Tor. I'm happy with setting my own proxy. Is there a recipe to do this?

What I expect: Run a docker container from an image, and get into a terminal where the VM can only connect to Internet through Tor. I'm happy with a Docker file that can do that.

If my question is still ambiguous, please feel free to ask for more details.

  • Yes it is possible.
    – james-see
    Dec 25, 2018 at 18:54
  • Please note that a docker container does not come with the same level of isolation as an actual VM.
    – Birb
    Sep 23, 2019 at 1:07
  • @Izmaki Can yo please elaborate on that? Sep 23, 2019 at 8:01
  • @TheQuantumPhysicist a docker container shares many things with its host such as the kernel. This, as an example, means that if your host kernel is vulnerable to an attack, an attacker may be able to go from a low privileges in the container to full privileges on the host machine. A VM has better "isolation" in that sense.
    – Birb
    Sep 23, 2019 at 21:31
  • just use torsocks type this sudo torsocks on then reload the program
    – MassHyper
    Oct 18, 2020 at 13:09

5 Answers 5


It's possible. Take a look at opnsense or tails. They have ability to transparently route all traffic through tor.


Yes this is possible and I have a WIP code on github that spins up a new dockerized hidden service server. This should point you in the right direction: https://github.com/jamesacampbell/stealth-tor-docker/blob/master/README.md YMMV.


This reminds me of Whonix. You could set up a Whonix VM "gateway" and connect whatever you wanted through that "gateway" (this is an assumption - all you need is access to the hypervisor network), like the regular "workstation" does. More info at https://www.whonix.org/wiki/About

If you change your requirement to "how can I run a VM through Tor only" then this applies.


I found this, maybe is what you ar looking for: https://github.com/bcapptain/dockernymous is like Whonix with Docker, creates 2 containers and redirects all traffic from container 1 through container 2, and container 2 has tor connection that anonymizes everything.


It depends on the OS that is hosting Docker. If it's Linux - it's just as easy as it can be via firewall: add a user-based rules for your container and run the container under the specific user, respectively

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .