Skip to content

Commit

Permalink
properly quote env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwh committed Oct 23, 2024
1 parent 909cb0f commit e6033d1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/levanter/infra/cli_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import base64
import os
import shlex
import subprocess
from typing import Optional

Expand Down Expand Up @@ -64,7 +65,7 @@ def make_docker_run_command(image_id, command, *, foreground, env, name="levante
"docker",
"run",
"-t" if foreground else "-d",
f"--name={name}",
f"--name={shlex.quote(name)}",
"--privileged",
"--shm-size=32gb",
"--net=host",
Expand All @@ -76,7 +77,9 @@ def make_docker_run_command(image_id, command, *, foreground, env, name="levante
]

for k, v in env.items():
docker_command.extend(["-e", k + f"={str(v)}"])
v = shlex.quote(str(v))
k = shlex.quote(str(k))
docker_command.extend(["-e", f"{k}={v}"])

docker_command.extend([image_id, *command])
return docker_command
Expand Down

0 comments on commit e6033d1

Please sign in to comment.