Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for in docker deployment before setting cgroup #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mininet/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,11 @@ def __init__(self, name, dimage=None, dcmd=None, build_params={},
debug("image: %s\n" % str(self.dimage))
debug("dcmd: %s\n" % str(self.dcmd))
info("%s: kwargs %s\n" % (name, str(kwargs)))

cgroup_parent = '/docker'
if os.environ.get("CONTAINERNET_NESTED") == "1": # Check if containernet is in a docker container and remove cgoup_parent if true
cgroup_parent = None


# creats host config for container
# see: https://docker-py.readthedocs.io/en/stable/api.html#docker.api.container.ContainerApiMixin.create_host_config
Expand All @@ -840,7 +845,7 @@ def __init__(self, name, dimage=None, dcmd=None, build_params={},
storage_opt=self.storage_opt,
# Assuming Docker uses the cgroupfs driver, we set the parent to safely
# access cgroups when modifying resource limits.
cgroup_parent='/docker'
cgroup_parent=cgroup_parent
)

if kwargs.get("rm", False):
Expand Down