brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: run a Docker container with no network at all for untrusted work

Docker
~/tips/tip-docker-network-none

docker run --rm --network none \

Cut a one-off container off from every network, with only loopback inside.

When a container only has to process files, it does not need a network. --network none gives it nothing but a loopback interface, so it cannot download anything or send your data anywhere.

docker run --rm --network none \
  -v "$PWD:/work:ro" -w /work \
  alpine sha256sum *.iso

Inside, ip addr shows only lo with 127.0.0.1. There is no DNS and no route, so any attempt to connect fails straight away.

I’d reach for it when running a tool you do not fully trust on your files: a converter from an unknown project, a script from a forum, a build of something you are still reviewing. Combined with a read-only mount of the input, the worst it can do is waste some CPU. It is also a quick test for whether an app really works offline.

Anything that needs to fetch a dependency during the run fails, often with confusing timeouts rather than a clear message. Install what you need in the image beforehand. In Compose the same setting is network_mode: none. It does not limit what the container can do with mounted files or the CPU, so pair it with :ro mounts and resource limits when the goal is containment.

Further reading: None network driver

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link