Skip to content

Commit 8ab638c

Browse files
committed
removed PRIVILIGED and ALLOWED_PUBLISH_PORTS_ALL config vars in favor of simple flags
1 parent 01bd1d9 commit 8ab638c

3 files changed

Lines changed: 12 additions & 26 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Backwards incompatibilities:
1313
- Executor nvidia-docker now includes configurable limits to NV_GPU env var.
1414
Before the default was to always make all GPUs available (see new config
1515
options below).
16+
- PRIVILEGED dropped (use ARGS_AVAILABLE, but let me know how this is useful
17+
with userdocker!)
18+
- ALLOWED_PUBLISH_PORTS_ALL dropped (use ARGS_AVAILABLE)
1619

1720
New features:
1821
-------------

userdocker/config/default.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@
6666
'version',
6767
]
6868

69-
# Arguments (more precisely simple flags) that you want to make available to the
70-
# user or enforce. Do not include args that are handled below (e.g. run -v)!
69+
# Simple arguments without options (flags):
70+
# Arguments (without options) that you want to enforce on the user:
71+
# Do not include args that are handled below (e.g. run -v)!
7172
# The following arguments will always be injected for the corresponding command:
7273
ARGS_ALWAYS = {
7374
'run': [
@@ -76,7 +77,9 @@
7677
'--rm',
7778
],
7879
}
79-
# The following arguments are available to the user for the given command:
80+
# The following arguments (without options) are available to the user for the
81+
# given command.
82+
# Do not include args that are handled below (e.g. run -v)!
8083
# (aliases are supported as tuples below, but not in ARGS_ALWAYS)
8184
ARGS_AVAILABLE = {
8285
'attach': [
@@ -105,6 +108,8 @@
105108
('-t', '--tty'),
106109
('-i', '--interactive'),
107110
'--read-only',
111+
# users can map all exposed container ports to random free host ports:
112+
('-P', '--publish-all'),
108113
],
109114
}
110115

@@ -153,18 +158,9 @@
153158
USER_IN_CONTAINER = True
154159

155160
# The following allows to drop / grant capabilities of all containers.
156-
# By default we drop all and make the
161+
# By default we drop all
157162
CAPS_DROP = ['ALL']
158163
CAPS_ADD = []
159-
PRIVILEGED = False
160-
161-
# User ability to publish ports
162-
# The ALLOWED_PUBLISH_PORTS_ALL allows the user to use the -P flag, which
163-
# publishes all ports that are EXPOSEd in the container to random host ports
164-
# (non priv range).
165-
# Notice that by default such ports are world accessible, so in case you want to
166-
# protect them, make sure to have (a docker compatible) iptables in place.
167-
ALLOWED_PUBLISH_PORTS_ALL = True
168164

169165
# Environment vars to set for the container:
170166
ENV_VARS = [

userdocker/subcommands/run.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77

88
from .. import __version__
99
from ..config import ALLOWED_IMAGE_REGEXPS
10-
from ..config import ALLOWED_PUBLISH_PORTS_ALL
1110
from ..config import CAPS_ADD
1211
from ..config import CAPS_DROP
1312
from ..config import ENV_VARS
1413
from ..config import ENV_VARS_EXT
1514
from ..config import NV_ALLOWED_GPUS
1615
from ..config import NV_DEFAULT_GPU_COUNT_RESERVATION
1716
from ..config import NV_MAX_GPU_COUNT_RESERVATION
18-
from ..config import PRIVILEGED
1917
from ..config import PROBE_USED_MOUNTS
2018
from ..config import RUN_PULL
2119
from ..config import USER_IN_CONTAINER
@@ -52,13 +50,6 @@ def parser_run(parser):
5250
default=[],
5351
)
5452

55-
if ALLOWED_PUBLISH_PORTS_ALL:
56-
sub_parser.add_argument(
57-
"-P", "--publish-all",
58-
help="Publish all exposed ports to random ports",
59-
action="store_true",
60-
)
61-
6253
sub_parser.add_argument(
6354
"--entrypoint",
6455
help="Overwrite the default ENTRYPOINT of the image",
@@ -207,8 +198,6 @@ def exec_cmd_run(args):
207198
for mount in mounts:
208199
cmd += ["-v", mount]
209200

210-
if args.publish_all:
211-
cmd += ["-P"]
212201

213202
if args.executor == 'nvidia-docker':
214203
prepare_nvidia_docker_run(args)
@@ -230,8 +219,6 @@ def exec_cmd_run(args):
230219
cmd += ["--cap-drop=%s" % cap_drop]
231220
for cap_add in CAPS_ADD:
232221
cmd += ["--cap-add=%s" % cap_add]
233-
if PRIVILEGED:
234-
cmd += ["--privileged"]
235222

236223
if args.workdir:
237224
cmd += ["-w", args.workdir]

0 commit comments

Comments
 (0)