From 89be45b20b6a7df91b788a026631964c69ced0be Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Tue, 8 Jun 2021 11:49:06 -0700 Subject: [PATCH 01/15] Workaround missing upstream dependency on six (#151) From: https://github.com/docker/docker-py/issues/2807 --- .github/workflows/basic-ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/basic-ci.yaml b/.github/workflows/basic-ci.yaml index 4b0d3c22..1bff4f2f 100644 --- a/.github/workflows/basic-ci.yaml +++ b/.github/workflows/basic-ci.yaml @@ -17,6 +17,8 @@ jobs: - name: Install Dependencies And Self run: | python -m pip install --upgrade pip setuptools wheel + # Workaround for https://github.com/docker/docker-py/issues/2807 + python -m pip install six pip install codecov coverage nose pip install . - name: Run headless tests From 8ecaf530cc374b30be121eef7a324b8200788eea Mon Sep 17 00:00:00 2001 From: Miguel Prada Date: Tue, 8 Jun 2021 20:52:58 +0200 Subject: [PATCH 02/15] Fix os detection for non-root images (cont.) (#150) * Quick fix for the case of running nvidia extensions with non-root container * Collapse 'chmod' into previous RUN command Co-authored-by: Jon Azpiazu --- src/rocker/os_detector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rocker/os_detector.py b/src/rocker/os_detector.py index 94640431..6054aae2 100644 --- a/src/rocker/os_detector.py +++ b/src/rocker/os_detector.py @@ -35,7 +35,7 @@ RUN echo 'import distro; import sys; output = distro.linux_distribution(); print(output) if output[0] else sys.exit(1)' > /tmp/distrovenv/detect_os.py RUN . /tmp/distrovenv/bin/activate && pyinstaller --onefile /tmp/distrovenv/detect_os.py -RUN . /tmp/distrovenv/bin/activate && staticx /dist/detect_os /dist/detect_os_static +RUN . /tmp/distrovenv/bin/activate && staticx /dist/detect_os /dist/detect_os_static && chmod go+xr /dist/detect_os_static FROM %(image_name)s From dc046c7d0965892d5dbb8156aefa8306c74fd4fb Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Tue, 8 Jun 2021 18:51:54 -0700 Subject: [PATCH 03/15] Squashed commit of the following: commit 0f1784031971ba52848a48c31bdc82f6cf85c182 Author: Tully Foote Date: Tue Jun 8 18:49:19 2021 -0700 improve documentation of abspath commit 5a59e98c06a81b18ffb5d3b149a3d5ede19da447 Merge: 8ecaf53 ca75cc5 Author: Tully Foote Date: Tue Jun 8 18:45:53 2021 -0700 Merge branch 'feature-mount' of github.com:plusone-robotics/rocker into plusone-robotics-feature-mount commit ca75cc56210cee8759dfe3c0b1458e85d90a7fa3 Author: Shane Loretz Date: Thu Jun 20 09:15:00 2019 -0700 Document --volume Signed-off-by: Shane Loretz commit a735938b49163c0c6bb6eff752214ae79eb0b023 Author: Isaac I.Y. Saito <130s@2000.jukuin.keio.ac.jp> Date: Mon Apr 19 09:40:12 2021 -0400 [volume] Rename from 'mount' (addressing https://github.com/osrf/rocker/pull/46#discussion_r301416615) commit 07ce911c2f1b3892055c9c9854570fe48971d6e5 Author: Isaac I.Y. Saito <130s@2000.jukuin.keio.ac.jp> Date: Sun Apr 18 13:26:02 2021 -0400 [mount] Add unit test. [test][mount] Add a test case for multiple mount points. commit fdb70942e393aab65473480b54a502233a98ea65 Author: Isaac I.Y. Saito <130s@2000.jukuin.keio.ac.jp> Date: Sun Apr 18 12:33:11 2021 -0400 [volume] Remove empty child methods. API doc. Variblizing. commit e734e2116e31968773a67259e0d916a98a258355 Author: Johannes Meyer Date: Fri Aug 30 12:05:58 2019 +0200 Allow to specify mount options more than once commit 425292cdb40c07c65a93e9e2e756ebd70a63af26 Author: Johannes Meyer Date: Tue Aug 27 17:20:52 2019 +0200 mount_extension: enable --mount arguments in format HOST-DIR[:CONTAINER-DIR[:OPTIONS]] commit 200dba19dacd478a1d7156b290af9bdc722acfe5 Author: Shane Loretz Date: Thu Jun 20 09:12:09 2019 -0700 Add Mount extension Signed-off-by: Shane Loretz --- README.md | 18 +++++++++ setup.py | 1 + src/rocker/volume_extension.py | 70 ++++++++++++++++++++++++++++++++++ test/test_volume.py | 69 +++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 src/rocker/volume_extension.py create mode 100644 test/test_volume.py diff --git a/README.md b/README.md index a33585ea..668feaa7 100644 --- a/README.md +++ b/README.md @@ -139,3 +139,21 @@ On Xenial On Bionic rocker --nvidia --x11 osrf/ros:melodic-desktop-full gazebo + +## Volume mount + +For arguments with one element not colon separated. + +`--volume` adds paths as docker volumes. The last path must be terminated with two dashes `--`. + + rocker --volume ~/.vimrc ~/.bashrc -- ubuntu:18.04 + +The above example of the volume option will be expanded via absolute paths for `docker run` as follows: + + --volume /home//.vimrc:/home//.vimrc --volume /home//.bashrc:/home//.bashrc + +For arguments with colon separation it will process the same as `docker`'s `--volume` option, `rocker --volume` takes 3 fields. +- 1st field: the path to the file or directory on the host machine. +- 2nd field: (optional) the path where the file or directory is mounted in the container. + - If only the 1st field is supplied, same value as the 1st field will be populated as the 2nd field. +- 3rd field: (optional) bind propagation as `ro`, `z`, and `Z`. See [docs.docker.com](https://docs.docker.com/storage/bind-mounts/) for further detail. diff --git a/setup.py b/setup.py index f52823a4..15921151 100644 --- a/setup.py +++ b/setup.py @@ -46,6 +46,7 @@ 'env = rocker.extensions:Environment', 'git = rocker.git_extension:Git', 'home = rocker.extensions:HomeDir', + 'volume = rocker.volume_extension:Volume', 'name = rocker.extensions:Name', 'network = rocker.extensions:Network', 'nvidia = rocker.nvidia_extension:Nvidia', diff --git a/src/rocker/volume_extension.py b/src/rocker/volume_extension.py new file mode 100644 index 00000000..dd571b2e --- /dev/null +++ b/src/rocker/volume_extension.py @@ -0,0 +1,70 @@ +# Copyright 2019 Open Source Robotics Foundation + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from argparse import ArgumentTypeError +import os +from rocker.extensions import RockerExtension + + +class Volume(RockerExtension): + + ARG_DOCKER_VOLUME = "-v" + ARG_ROCKER_VOLUME = "--volume" + name = 'volume' + + @classmethod + def get_name(cls): + return cls.name + + def get_docker_args(self, cli_args): + """ + @param cli_args: {'volume': [[%arg%]]} + - 'volume' is fixed. + - %arg% can be: + - %path_host%: a path on the host. Same path will be populated in + the container. + - %path_host%:%path_cont% + - %path_host%:%path_cont%:%option% + """ + args = [''] + + # flatten cli_args['volume'] + volumes = [ x for sublist in cli_args[self.name] for x in sublist] + + for volume in volumes: + elems = volume.split(':') + host_dir = os.path.abspath(elems[0]) + if len(elems) == 1: + args.append('{0} {1}:{1}'.format(self.ARG_DOCKER_VOLUME, host_dir)) + elif len(elems) == 2: + container_dir = elems[1] + args.append('{0} {1}:{2}'.format(self.ARG_DOCKER_VOLUME, host_dir, container_dir)) + elif len(elems) == 3: + container_dir = elems[1] + options = elems[2] + args.append('{0} {1}:{2}:{3}'.format(self.ARG_DOCKER_VOLUME, host_dir, container_dir, options)) + else: + raise ArgumentTypeError( + '{} expects arguments in format HOST-DIR[:CONTAINER-DIR[:OPTIONS]]'.format(self.ARG_ROCKER_VOLUME)) + + return ' '.join(args) + + @staticmethod + def register_arguments(parser): + parser.add_argument(Volume.ARG_ROCKER_VOLUME, + metavar='HOST-DIR[:CONTAINER-DIR[:OPTIONS]]', + type=str, + nargs='+', + action='append', + help='volume volumes in container') diff --git a/test/test_volume.py b/test/test_volume.py new file mode 100644 index 00000000..d9f4fda5 --- /dev/null +++ b/test/test_volume.py @@ -0,0 +1,69 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import os +import unittest + +from rocker.core import list_plugins +from rocker.volume_extension import Volume + + +class VolumeTest(unittest.TestCase): + def setUp(self): + self._instance = Volume() + self._curr_path = os.path.abspath(os.path.curdir) + self._virtual_path = "/path/in/container" + + def _test_equals_args(self, mock_cliargs, expected): + """ + @type mock_cliargs: { str: [[str]] } + @type expected: [[str]] + """ + print("DEBUG: 'mock_cliargs' {}\n\t'expected': {}".format(mock_cliargs, expected)) + docker_args = self._instance.get_docker_args(mock_cliargs) + print("DEBUG: Resulted docker_args: {}".format(docker_args)) + for arg_expected in expected: + # Whitespace at the beginning is needed. + complete_expected = " {} {}".format(Volume.ARG_DOCKER_VOLUME, arg_expected[0]) + self.assertTrue(complete_expected in docker_args) + + def test_args_single(self): + """Passing source path""" + arg = [[self._curr_path]] + expected = [['{}:{}'.format(self._curr_path, self._curr_path)]] + mock_cliargs = {Volume.name: arg} + self._test_equals_args(mock_cliargs, expected) + + def test_args_twopaths(self): + """Passing source path, dest path""" + arg = ["{}:{}".format(self._curr_path, self._virtual_path)] + mock_cliargs = {Volume.name: [arg]} + self._test_equals_args(mock_cliargs, arg) + + def test_args_twopaths_opt(self): + """Passing source path, dest path, and Docker's volume option""" + arg = ["{}:{}:ro".format(self._curr_path, self._virtual_path)] + mock_cliargs = {Volume.name: [arg]} + self._test_equals_args(mock_cliargs, arg) + + def test_args_two_volumes(self): + """Multiple volume points""" + arg_first = ["{}:{}:ro".format(self._curr_path, self._virtual_path)] + arg_second = ["/tmp:{}".format(os.path.join(self._virtual_path, "tmp"))] + args = [arg_first, arg_second] + mock_cliargs = {Volume.name: args} + self._test_equals_args(mock_cliargs, args) From 2760838dc4bc8c3bd436344ec8ab9225ad914696 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Tue, 3 Aug 2021 00:48:38 -0700 Subject: [PATCH 04/15] Fix detector for the deprecated distro syntax (#156) Fixes #155 Signed-off-by: Tully Foote --- src/rocker/os_detector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rocker/os_detector.py b/src/rocker/os_detector.py index 6054aae2..e5013926 100644 --- a/src/rocker/os_detector.py +++ b/src/rocker/os_detector.py @@ -32,7 +32,7 @@ RUN . /tmp/distrovenv/bin/activate && pip install distro pyinstaller==4.0 staticx RUN apt-get update && apt-get install -qy patchelf #needed for staticx -RUN echo 'import distro; import sys; output = distro.linux_distribution(); print(output) if output[0] else sys.exit(1)' > /tmp/distrovenv/detect_os.py +RUN echo 'import distro; import sys; output = (distro.name(), distro.version(), distro.codename()); print(output) if distro.name() else sys.exit(1)' > /tmp/distrovenv/detect_os.py RUN . /tmp/distrovenv/bin/activate && pyinstaller --onefile /tmp/distrovenv/detect_os.py RUN . /tmp/distrovenv/bin/activate && staticx /dist/detect_os /dist/detect_os_static && chmod go+xr /dist/detect_os_static From df0908489e6d28d34f489647a4622bb1596d9319 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Tue, 3 Aug 2021 00:57:54 -0700 Subject: [PATCH 05/15] using stretch slim package for less space and bandwidth requirements (#157) Signed-off-by: Tully Foote --- src/rocker/os_detector.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rocker/os_detector.py b/src/rocker/os_detector.py index e5013926..8013138c 100644 --- a/src/rocker/os_detector.py +++ b/src/rocker/os_detector.py @@ -21,7 +21,7 @@ DETECTION_TEMPLATE=""" -FROM python:3-stretch as detector +FROM python:3-slim-stretch as detector # Force the older version of debian for detector. # GLIBC is forwards compatible but not necessarily backwards compatible for pyinstaller # https://github.com/pyinstaller/pyinstaller/wiki/FAQ#gnulinux @@ -29,8 +29,10 @@ RUN mkdir -p /tmp/distrovenv RUN python3 -m venv /tmp/distrovenv +# patchelf needed for staticx +# binutils provides objdump needed by pyinstaller +RUN apt-get update && apt-get install -qy patchelf binutils RUN . /tmp/distrovenv/bin/activate && pip install distro pyinstaller==4.0 staticx -RUN apt-get update && apt-get install -qy patchelf #needed for staticx RUN echo 'import distro; import sys; output = (distro.name(), distro.version(), distro.codename()); print(output) if distro.name() else sys.exit(1)' > /tmp/distrovenv/detect_os.py RUN . /tmp/distrovenv/bin/activate && pyinstaller --onefile /tmp/distrovenv/detect_os.py From acbbff59d6aef6a9654eabc0ff7e3f823936d6e3 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Tue, 3 Aug 2021 12:22:41 -0700 Subject: [PATCH 06/15] 0.2.4 version bump Signed-off-by: Tully Foote --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 15921151..ce1a302c 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ kwargs = { 'name': 'rocker', - 'version': '0.2.3', + 'version': '0.2.4', 'packages': ['rocker'], 'package_dir': {'': 'src'}, 'package_data': {'rocker': ['templates/*.em']}, From ef0901419dd99132bef5c1b797892927e63f5925 Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Thu, 16 Sep 2021 01:41:23 -0700 Subject: [PATCH 07/15] Add an option to tag the image (#159) Signed-off-by: Tully Foote --- src/rocker/core.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index ac5ae979..9b87c400 100755 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -103,6 +103,8 @@ def extend_cli_parser(self, parser, default_args={}): parser.add_argument('--mode', choices=OPERATION_MODES, default=OPERATIONS_INTERACTIVE, help="Choose mode of operation for rocker") + parser.add_argument('--image-name', default=None, + help='Tag the final image, useful with dry-run') parser.add_argument('--extension-blacklist', nargs='*', default=[], help='Prevent any of these extensions from being loaded.') @@ -223,6 +225,10 @@ def build(self, **kwargs): arguments['rm'] = True arguments['nocache'] = kwargs.get('nocache', False) arguments['pull'] = kwargs.get('pull', False) + image_name = kwargs.get('image_name', None) + if image_name: + print(f"Running docker tag {self.image_id} {image_name}") + arguments['tag'] = image_name print("Building docker file with arguments: ", arguments) try: self.image_id = docker_build( @@ -256,7 +262,11 @@ def generate_docker_cmd(self, command='', **kwargs): for e in self.active_extensions: docker_args += e.get_docker_args(self.cliargs) - image = self.image_id + image_name = kwargs.get('image_name', None) + if image_name: + image = image_name + else: + image = self.image_id cmd = "docker run" if(not kwargs.get('nocleanup')): # remove container only if --nocleanup is not present From 32a1e6e2dab9c9ff9328e7dc72defb218c4f88eb Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Mon, 4 Oct 2021 18:04:17 -0700 Subject: [PATCH 08/15] pin staticx (#162) Signed-off-by: Tully Foote --- src/rocker/os_detector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rocker/os_detector.py b/src/rocker/os_detector.py index 8013138c..46a4295e 100644 --- a/src/rocker/os_detector.py +++ b/src/rocker/os_detector.py @@ -32,7 +32,7 @@ # patchelf needed for staticx # binutils provides objdump needed by pyinstaller RUN apt-get update && apt-get install -qy patchelf binutils -RUN . /tmp/distrovenv/bin/activate && pip install distro pyinstaller==4.0 staticx +RUN . /tmp/distrovenv/bin/activate && pip install distro pyinstaller==4.0 staticx==0.12.3 RUN echo 'import distro; import sys; output = (distro.name(), distro.version(), distro.codename()); print(output) if distro.name() else sys.exit(1)' > /tmp/distrovenv/detect_os.py RUN . /tmp/distrovenv/bin/activate && pyinstaller --onefile /tmp/distrovenv/detect_os.py From 0f2f13c3aaabb26d89a0c6ebd9b93cf3f714e0fa Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Mon, 4 Oct 2021 18:06:10 -0700 Subject: [PATCH 09/15] version bump 0.2.5 Signed-off-by: Tully Foote --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ce1a302c..f5ec14f9 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ kwargs = { 'name': 'rocker', - 'version': '0.2.4', + 'version': '0.2.5', 'packages': ['rocker'], 'package_dir': {'': 'src'}, 'package_data': {'rocker': ['templates/*.em']}, From 37a60a046fd858f4a0b812de70f88444ddae56cc Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Mon, 4 Oct 2021 21:36:01 -0700 Subject: [PATCH 10/15] bump to 0.2.6 Signed-off-by: Tully Foote --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f5ec14f9..a05f163b 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ kwargs = { 'name': 'rocker', - 'version': '0.2.5', + 'version': '0.2.6', 'packages': ['rocker'], 'package_dir': {'': 'src'}, 'package_data': {'rocker': ['templates/*.em']}, From c81c2ffa59223519bda810611ac981e97019b61f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 15 Nov 2021 12:03:34 +0100 Subject: [PATCH 11/15] Merge mount extension into the volume extension --mount is basically an alias for --volume now for backwards compatibility. --- setup.py | 1 - src/rocker/mount_extension.py | 110 --------------------------------- src/rocker/volume_extension.py | 4 +- 3 files changed, 2 insertions(+), 113 deletions(-) delete mode 100644 src/rocker/mount_extension.py diff --git a/setup.py b/setup.py index e4785855..95a505eb 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,6 @@ 'env = rocker.extensions:Environment', 'git = rocker.git_extension:Git', 'home = rocker.extensions:HomeDir', - 'mount = rocker.mount_extension:Mount', 'volume = rocker.volume_extension:Volume', 'name = rocker.extensions:Name', 'network = rocker.extensions:Network', diff --git a/src/rocker/mount_extension.py b/src/rocker/mount_extension.py deleted file mode 100644 index 3441b658..00000000 --- a/src/rocker/mount_extension.py +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright 2019 Open Source Robotics Foundation - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import argparse -from argparse import ArgumentTypeError -import os -from rocker.extensions import RockerExtension - - -class Mount(RockerExtension): - - name = 'mount' - - @classmethod - def get_name(cls): - return cls.name - - def precondition_environment(self, cli_args): - pass - - def validate_environment(self, cli_args): - pass - - def get_preamble(self, cli_args): - return '' - - def get_snippet(self, cli_args): - return '' - - def get_docker_args(self, cli_args): - args = [''] - - volumes = cli_args.get('volume') or [] - mounts = cli_args.get('mount') or [] - # flatten cli_args['mount'] - if mounts: - mounts = [ x for sublist in cli_args['mount'] for x in sublist] - - # for backwards compatibility: - # - interpret --mount arguments without commas with colons like --volume - # - interpret --mount arguments without commas and without colons as a single host folder - # (absolute or relative to the current working directory) that will be mounted - # under the same name in the container - temp = [] - for mount in mounts: - elems = mount.split(',') - if len(elems) == 1: - if ':' in elems[0]: - volumes.append(elems[0]) - else: - host_dir = os.path.abspath(elems[0]) - args.append('-v {0}:{0}'.format(host_dir)) - else: - temp.append(mount) - mounts = temp - - # --mount arguments are forwarded as-is. - for mount in mounts: - args.append('--mount {0}'.format(mount)) - - # --volumes/-v are eventually resolved relative to the current working directory, but otherwise - # forwarded as-us. - for volume in volumes: - elems = volume.split(':') - host_dir = os.path.abspath(elems[0]) - if len(elems) == 1: - args.append('-v {0}:{0}'.format(host_dir)) - elif len(elems) == 2: - container_dir = elems[1] - args.append('-v {0}:{1}'.format(host_dir, container_dir)) - elif len(elems) == 3: - container_dir = elems[1] - options = elems[2] - args.append('-v {0}:{1}:{2}'.format(host_dir, container_dir, options)) - else: - raise ArgumentTypeError('--volume expects arguments in format HOST-DIR[:CONTAINER-DIR[:OPTIONS]]') - - return ' '.join(args) - - @staticmethod - def register_arguments(parser, defaults={}): - parser.add_argument('-v', '--volume', - metavar='HOST-DIR[:CONTAINER-DIR[:OPTIONS]]', - type=str, - action='append', - default=defaults.get('volume', argparse.SUPPRESS), - help='mount volumes in container (equivalent to docker run -v)') - parser.add_argument('--mount', - metavar='=[,=[,...]]', - type=str, - nargs='+', - action='append', - default=defaults.get('mount', argparse.SUPPRESS), - help='mount volumes in container (equivalent to docker run --mount)') - - @classmethod - def check_args_for_activation(cls, cli_args): - """ Returns true if the arguments indicate that this extension should be activated otherwise false.""" - return cli_args.get('volume') or cli_args.get('mount') diff --git a/src/rocker/volume_extension.py b/src/rocker/volume_extension.py index dd571b2e..1f7d4265 100644 --- a/src/rocker/volume_extension.py +++ b/src/rocker/volume_extension.py @@ -20,7 +20,7 @@ class Volume(RockerExtension): ARG_DOCKER_VOLUME = "-v" - ARG_ROCKER_VOLUME = "--volume" + ARG_ROCKER_VOLUME = ["--volume", "--mount"] name = 'volume' @classmethod @@ -62,7 +62,7 @@ def get_docker_args(self, cli_args): @staticmethod def register_arguments(parser): - parser.add_argument(Volume.ARG_ROCKER_VOLUME, + parser.add_argument(*Volume.ARG_ROCKER_VOLUME, metavar='HOST-DIR[:CONTAINER-DIR[:OPTIONS]]', type=str, nargs='+', From b9637f7fb47f8596c8b5bdd95036dc21e1609841 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 15 Nov 2021 12:11:40 +0100 Subject: [PATCH 12/15] Do not tag os_detect images This commit partially reverts 80602eb6868a9044279d88c13650828f654a32f9 (https://github.com/osrf/rocker/pull/133). See https://github.com/osrf/rocker/pull/133#issuecomment-941622117. --- src/rocker/os_detector.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rocker/os_detector.py b/src/rocker/os_detector.py index df482c5e..65b041bb 100644 --- a/src/rocker/os_detector.py +++ b/src/rocker/os_detector.py @@ -59,7 +59,6 @@ def detect_os(image_name, output_callback=None, nocache=False): output_callback=output_callback, nocache=nocache, forcerm=True, # Remove intermediate containers from RUN commands in DETECTION_TEMPLATE - tag="rocker:" + f"os_detect_{image_name}".replace(':', '_').replace('/', '_') ) if not image_id: if output_callback: From 55db75f10f72c2698d13a6c566873a7735f6c7e6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 15 Nov 2021 12:13:09 +0100 Subject: [PATCH 13/15] setup.cfg: reset debian-version to 1intermodalics for 0.2.6 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index f6b157b6..61cf1453 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,3 @@ [sdist_dsc] epoch: 1 -debian-version: 4intermodalics +debian-version: 1intermodalics From 939fee62513b5c82b718c88311410b5c8a546d79 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 18 Nov 2021 15:43:45 +0100 Subject: [PATCH 14/15] Do not use f-strings for compatibility with Xenial Co-authored-by: SergioPD <58431488+spd-intermodalics@users.noreply.github.com> --- src/rocker/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index cb87fb4b..3a211484 100755 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -227,7 +227,7 @@ def build(self, **kwargs): arguments['pull'] = kwargs.get('pull', False) image_name = kwargs.get('image_name', None) if image_name: - print(f"Running docker tag {self.image_id} {image_name}") + print("Running docker tag {} {}".format(self.image_id, image_name)) arguments['tag'] = image_name print("Building docker file with arguments: ", arguments) try: From d9dd1dfcb962698d45b7690e1d2b6d35786e0ef9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 18 Nov 2021 15:48:17 +0100 Subject: [PATCH 15/15] setup.cfg: bump to debian version 2intermodalics --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 61cf1453..12181301 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,3 @@ [sdist_dsc] epoch: 1 -debian-version: 1intermodalics +debian-version: 2intermodalics