0

Is there a way to eliminate internet capability from inside a container? I would like to configure Docker on Ubuntu where containers can only run on an internal network and only communicate with other containers on that network. By quickly playing around it seems that this may be difficult to do as a user can (1) create their own network that is configured to bridge with the host and become internet-facing. Or (2) just run off the default bridge network. From what I understand is that the Docker application is immune to any Unix type controls and Docker does not allow you to remove the pre-defined networks anyway. Is there a solution to this? It seems dangerous to allow users to configure their own container networks. Am I able to modify the default bridge network to be internal? Am I able to restrict network creation?

1
  • Also, as said in this Docker document docs.docker.com/network/bridge, that the default bridge network has its shortcomings and is not recommended for production use. This makes sense, however they do not offer a solution outside of configuring your own. This is not a solution for a controlled corporate environment however as a user can just avoid using said network. Commented Jul 5, 2022 at 23:12

1 Answer 1

1

It seems dangerous to allow users to configure their own container networks.

You seem to have a fundamental misapprehension about Docker: it's not meant, out of the box, to be a multi-user tool. Having access to Docker is equivalent to having root access on a host. If you want to provide some sort of multi-tenant container environment, you need to look at tools like Kubernetes that implement various access control mechanisms on top of some sort of container runtime.

Docker does have support for authorization plugins, so perhaps there is something you could implement using that feature.

Note that there are more secure alternatives: Podman has been providing rootless containers for a while, and even Docker now provides a rootless mode of operation.

These options eliminate the bulk of the security issues with Docker, but they have their own limitations (I haven't worked with rootless Docker, but I use Podman regularly and it's compatibility with docker-compose is only so-so).

Is there a way to eliminate internet capability from inside a container?

Sure, create a --internal network, and run your containers on that network:

$ docker network create --internal mynetwork $ docker run -it --rm --network mynetwork docker.io/alpine:latest sh 

You can't enforce use of this network, but you can certainly use it when deploying your own containers.

Also, as said in this Docker document docs.docker.com/network/bridge, that the default bridge network has its shortcomings and is not recommended for production use. This makes sense, however they do not offer a solution outside of configuring your own

The documentation describes how you can create additional bridge networks (or other sorts of networks) using the docker network create command. These networks do not suffer many of the limitations of the default bridge network (for example, Docker maintains DNS service on these networks so containers can refer to each other by name).

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for the insight, I should have stated my current scenario better. While deploying Kubernetes is on the road map, we are not at that point yet. So currently to sidestep compliancy there needs to be a level of network configuration and security where users are restricted in what they can do. Without setup obviously Docker lacks a good system of access control, so we look to deploy images with preconfigured restrictions. Creating an --internal network would do the trick, but that's easily voidable by a user that can modify networks, or just use the default network.
Pretty much from my understanding, without added plugins or Kubernetes, Docker cannot be configured to a level that meets security needs.
I'll have to look more into it, but it seems that authorization plugins could be the solution to this issue.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.