diff --git a/docker-run-cli/src/docker_run/core.py b/docker-run-cli/src/docker_run/core.py index 5dd2071..6b51630 100644 --- a/docker-run-cli/src/docker_run/core.py +++ b/docker-run-cli/src/docker_run/core.py @@ -21,6 +21,7 @@ if isinstance(cls, type) and issubclass(cls, Plugin) and cls is not Plugin: PLUGINS.append(cls) +DEFAULT_CONTAINER_NAME = validDockerContainerName(os.path.basename(os.getcwd())) def parseArguments() -> Tuple[argparse.Namespace, List[str], List[str]]: @@ -45,7 +46,7 @@ def format_help(self): parser.add_argument("--help", action="help", default=argparse.SUPPRESS, help="show this help message and exit") parser.add_argument("--image", help="image name (may also be specified without --image as last argument before command)") - parser.add_argument("--name", default=validDockerContainerName(os.path.basename(os.getcwd())), help="container name; generates `docker exec` command if already running") + parser.add_argument("--name", default=DEFAULT_CONTAINER_NAME, help="container name; generates `docker exec` command if already running") parser.add_argument("--no-name", action="store_true", help="disable automatic container name (current directory)") parser.add_argument("--verbose", action="store_true", help="print generated command") parser.add_argument("--version", action="store_true", help="show program's version number and exit") @@ -94,7 +95,7 @@ def buildDockerCommand(args: Dict[str, Any], unknown_args: List[str] = [], cmd_a running_containers = runCommand('docker ps --format "{{.Names}}"')[0].split('\n') new_container = not (args["name"] in running_containers) if not new_container and args["image"] is not None and len(args["image"]) > 0: - args["name"] = None if args["name"] == validDockerContainerName(os.path.basename(os.getcwd())) else args["name"] + args["name"] = None if args["name"] == DEFAULT_CONTAINER_NAME else args["name"] new_container = True if new_container: # docker run