Create a Docker container without internet access
Solution 1:
Use the none network: "The none network adds a container to a container-specific network stack. That container lacks a network interface"
For example, you can run a container without network interfaces attached to it specifying none as the network:
docker run --net none -it alpine /bin/sh
See that only the loopback interface is attached:
/ # ifconfig -a
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)