Skip to content

Commit

Permalink
Add --network-mode option
Browse files Browse the repository at this point in the history
  • Loading branch information
rhjostone committed Jan 30, 2025
1 parent adc3bbe commit 04c66ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,15 @@ def run_parser(subparsers):
parser.add_argument(
"ARGS", nargs="*", help="Overrides the default prompt, and the output is returned without entering the chatbot"
)
# Disable network access by default, and give the option to pass any supported network mode into
# podman if needed:
# https://docs.podman.io/en/latest/markdown/podman-run.1.html#network-mode-net
parser.add_argument(
"--network-mode",
type=str,
default="none",
help="Set the network mode for the container.",
)
parser.set_defaults(func=run_cli)


Expand Down
3 changes: 3 additions & 0 deletions ramalama/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def setup_container(self, args):
name,
]

if args.subcommand == 'run':
conman_args += [f"--network={args.network_mode}"]

if os.path.basename(args.engine) == "podman":
conman_args += ["--pull=newer"]
elif os.path.basename(args.engine) == "docker":
Expand Down

0 comments on commit 04c66ab

Please sign in to comment.