Open Viktor45 opened 3 months ago
Due to the way clap
is parsing arguments for the container command (set to a trailing_var_arg
, see cli::container::Container
) and that you have -d
as the first argument after the image, it's being treated as a second --detach
. It's not "all arguments" as you claimed. This can be confirmed with the following command, switching -d 1
and -s 1
:
podlet podman run --replace --net=host \
--cap-add=NET_ADMIN --cap-add=SYS_ADMIN --cap-add=CAP_MKNOD --security-opt="label=disable" \
-v /var/app/list.txt:/list.txt:z \
--device=/dev/net/tun --device=/dev/null \
--name cdpi -d localhost/my-cdpi:latest -s 1 -d 1 -H /list.txt
Which successfully generates the .container
file:
# cdpi.container
[Container]
AddCapability=NET_ADMIN SYS_ADMIN CAP_MKNOD
AddDevice=/dev/net/tun
AddDevice=/dev/null
ContainerName=cdpi
Exec=-s 1 -d 1 -H /list.txt
Image=localhost/my-cdpi:latest
Network=host
SecurityLabelDisable=true
Volume=/var/app/list.txt:/list.txt:z
trailing_var_arg
positional arguments (with allow_hyphen_values
set) start collecting values at the first unrecognized argument (-s
in the above example) or after --
(e.g., podlet podman run image -- command
).
Unfortunately, I can't think of a good solution to this problem. The only thing I can think of is to combine the image
and command
fields/arguments in cli::container::Container
(also removing allow_hyphen_values
) and then separate out the image in the conversion. However, that screws up the usage and arguments in the help for podlet podman run
, so that's no good. Hopefully someone can come up with a better solution.
Podlet parses all arguments as podman arguments, instead to parse it like podman container arguments.
Here is the example.
Command to run container with extra container arguments.
Note the extra container arguments
-d 1 -s 1 -H /list.txt
.Command to generate podlet from running containers
podlet generate container cdpi
Got error: