Skip to content

--podman-args args are not passed to podman #707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gwallet opened this issue Jun 9, 2023 · 6 comments
Open

--podman-args args are not passed to podman #707

gwallet opened this issue Jun 9, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@gwallet
Copy link

gwallet commented Jun 9, 2023

Describe the bug
I want to use the remote capability of docker to deploy containers on a remote host.
podman-compose knows nothing about this feature, but the doc says:

...
--podman-args args    custom global arguments to be passed to `podman`
...

I'm understanding that one can pass argument to podman thanks to --podman-args.
The hope here is to let podman-compose talk locally to podman, using --podman-args="--remote" the later will be driving a remote host, and that it will be smooth.

There are also several --podman-{CMD}-args flags to pass arguments to dedicated command, which is not what I'm looking for. (at least, not at the moment)

To Reproduce
Steps to reproduce the behavior:
0. setup a remote host with podman installed and ready to serve remotely

  • Fedora Server 38 in a small VM in VirtualBox
  • setup remote access with key pairs (ssh-copy-id …)
  • enable podman.socket on the host
  • make a container running
  1. add a podman connection to the host
  • $ podman system connection add --default remote ssh://user@remote
  1. check the remote access with podman
  • $ podman --remote container ls
  • ✅ it returns the list of running container on the remote host and not on the localhost
  1. check the remote access with podman-compose
  • $ podman-compose --project-name my-project --podman-args="--remote" ps
  • ❎ the following error occurs
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.5.0
podman ps --remote -a --filter label=io.podman.compose.project=my-project
Error: unknown flag: --remote
See 'podman ps --help'
exit code: 125

The --remote flag is set after ps and not after podman

  1. podman is doing well when asking with the right command line:
  • $ podman --remote ps -a --filter label=io.podman.compose.project=my-project list all the container running remotely

Expected behavior
Running podman-compose --help says

...
--podman-args args    custom global arguments to be passed to `podman`
...

I'm expecting the args to be passed to podman and not the the sub-command:
Expecting:
podman --remote ps -a --filter label=io.podman.compose.project=my-project
Got:
podman ps --remote -a --filter label=io.podman.compose.project=my-project

Actual behavior
Actually, arguments sent to podman-compose via --podman-args are given to the sub-command and not to podman globally as mentioned in the doc.

Output

$ podman-compose version
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.5.0
podman-compose version 1.0.6
podman --version 
podman version 4.5.0
exit code: 0

Environment:

  • OS: Linux (local: Fedora Workstation 37 / remote: Fedora Server 38)
  • podman version: local: 4.5.0 / remote: 4.5.1
  • podman compose version: 1.0.6

Additional context

As a workaround, it's always possibe to send podman-compose commands via SSH,
but want to avoid sending the compose file via SCP, and keeping things on the driver computer.

I hope it's clear, if not I'll be happy to clarify 🙂

Regards,

@gwallet gwallet added the bug Something isn't working label Jun 9, 2023
@onursoyer
Copy link

I can confirm the error mentioned above.

When executing the following code, it throws an error:

podman-compose --podman-args "-c p1-root" up
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.5.0
** excluding:  set()
['podman', 'ps', '-c', 'p1-root', '--filter', 'label=io.podman.compose.project=docker', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
Error: unknown shorthand flag: 'c' in -c
See 'podman ps --help'
Traceback (most recent call last):
  File "/usr/bin/podman-compose", line 33, in <module>
    sys.exit(load_entry_point('podman-compose==1.0.6', 'console_scripts', 'podman-compose')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 2940, in main
    podman_compose.run()
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 1422, in run
    cmd(self, args)
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 1753, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 2037, in compose_up
    compose.podman.output(
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 1097, in output
    return subprocess.check_output(cmd_ls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['podman', 'ps', '-c', 'p1-root', '--filter', 'label=io.podman.compose.project=docker', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']' returned non-zero exit status 125.

It looks like podman-compose executes podman ps first and then inserts the 'podman-args' arguments afterwards. Therefore, it does not work. The execution order should be reversed as for example podman -c p1 ps instead of podman ps -c p1.

@francoism90
Copy link

Did you ever found a solution?

This seems to work for me:

podman-compose --podman-run-args="--cpus=1.5" up -d 

@Bahlaouane-Hamza
Copy link

Install podman-remote, setup a remote connection and then use it like so

$ podman-compose --podman-path="/usr/bin/podman-remote" ps

@Jakuje
Copy link

Jakuje commented May 13, 2024

Note, that there are still conrner cases that dont work with the approach if the compose references some local volumes, their absolute path needs to exist on the remote machine running the podman.

@francoism90
Copy link

I've moved on to Quadlet e.g systemd containers. This also gives you the benefits of applying quota flags, and you can even apply system(d) settings.

The only disadvantages is that it only works for systemd and the user needs to place/sync container files, instead of providing one simple compose file.

@hunter86bg
Copy link

I was attempting the following but it also fails:

podman-compose --podman-start-args="--health-on-failure=restart" up -d

Sadly, podman-compose doesn't support restart pod on failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants