Comments (9)
Sorry for my bad Pythonese. Your solution using cmd_quote
is much better.
I tested your latest change and it doesn't handle all cases correctly. Please see the latest commit I pushed to my fork. Do you want a PR for it or can you cherry-pick it?
from podman-compose.
if my comments in podman
are taken in consideration
containers/podman#3507 (comment)
the code should be like
if is_str(healthcheck_test):
# podman does not add shell to handle command with whitespace
args.extend(['--healthcheck-command', healthcheck_test])
elif is_list(healthcheck_test):
# If itβs a list, first item is either NONE, CMD or CMD-SHELL.
healthcheck_type = healthcheck_test.pop(0)
if healthcheck_type == 'NONE':
args.append("--no-healthcheck")
elif healthcheck_type == 'CMD':
args.extend(['--healthcheck-command', json.dumps(healthcheck_test)])
elif healthcheck_type == 'CMD-SHELL':
if len(healthcheck_test)!=1:
raise ValueError("'CMD_SHELL' takes a single string after it")
args.extend(['--healthcheck-command', healthcheck_test])
from podman-compose.
Don't know if that error has anything with this:
File "/home/thomas/bin/podman-compose", line 506
args.extend(['--healthcheck-command', '/bin/sh -c {}'.format(cmd_quote(healthcheck_test[0])]))
^
SyntaxError: invalid syntax
on current master (e21932e)
from podman-compose.
@chpio I noticed that too and fixed it in my patch stefanb2/podman-compose@d1583d5b
from podman-compose.
@chpio I've fixed the typo, please tell me if it fixed the issue
@stefanb2 I did not like quoting the whole thing as you did
args.extend(['--healthcheck-command', cmd_quote('/bin/sh -c {}'.format(cmd_quote(healthcheck_test)))])
args.extend(['--healthcheck-command', cmd_quote(' '.join([cmd_quote(i) for i in healthcheck_test])
args.extend(['--healthcheck-command', cmd_quote('/bin/sh -c {}'.format(cmd_quote(healthcheck_test[0])))])
because when we pass arrays ["something", "otherthing"]
the string is passed as is, no need for extra escaping.
anyway, I'm following podman
ticket to see what they will do. I hope they solve it in a way I can pass a string or of a list json.dumps(ls)
it's not compose job to work with shell, compose does not even know which shell to use (bash, sh, or zsh), if I want to inspect the image to know the shell, I might need to pull it first, but I can't pull it every time if it's already pulled. (it's a lot of job to do in compose)
on the other hand, podman knows.
from podman-compose.
@muayyad-alsadi oops I just looked at the generated command lines and missed the fact that your are not passing them to the shell. Just forget my change then.
from podman-compose.
@chpio I've fixed the typo, please tell me if it fixed the issue
yeah, thank you for that
from podman-compose.
I am seeing an error here:
Traceback (most recent call last):
File "/opt/homebrew/bin/podman-compose", line 33, in <module>
sys.exit(load_entry_point('podman-compose==1.0.6', 'console_scripts', 'podman-compose')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 2941, in main
podman_compose.run()
File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 1423, in run
cmd(self, args)
File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 1754, in wrapped
return func(*args, **kw)
^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 2067, in compose_up
podman_args = container_to_args(compose, cnt, detached=args.detach)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/podman-compose/1.0.6/libexec/lib/python3.11/site-packages/podman_compose.py", line 999, in container_to_args
raise ValueError("'CMD_SHELL' takes a single string after it")
ValueError: 'CMD_SHELL' takes a single string after it
The health check in my compose file:
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-U", "$PGUSER", "-d", "$PGDATABASE"]
I was able to get around this by using CMD
and switching the $PGUSER
and $PGDATABASE
strings to reference variables in the compose file. However, it would be nice to have this fixed.
from podman-compose.
Healthcheck not working on podman-compose (not tested on docker) if /bin/sh not available in container even when using CMD in heathcheck.test (reproduction).
$ podman version
Client: Podman Engine
Version: 4.9.0
API Version: 4.9.0
Go Version: go1.21.6
Built: Wed Jan 24 13:07:27 2024
OS/Arch: linux/amd64
services:
test:
build:
context: .
container_name: healthcheck_test
healthcheck:
test: [
"CMD",
"/healthcheck",
"http://localhost:8080/ping"
]
interval: 5s
timeout: 5s
retries: 5
podman inspect --format "{{json .State.Health }}" healthcheck_test | jq
{
"Status": "unhealthy",
"FailingStreak": 18,
"Log": [
{
"Start": "2024-02-15T10:34:44.046709663+03:00",
"End": "2024-02-15T10:34:44.131872722+03:00",
"ExitCode": 1,
"Output": ""
},
from podman-compose.
Related Issues (20)
- `network_mode: none` is ignored
- Error in podman-compose up command HOT 3
- Mismatch of Documentation and Implementation of UID/GID Mappings
- Replicate environment variable from local environment fails with default `.env` -file HOT 3
- Support changing `io.podman` label domain namespace
- Doc about systemd unit generation missing or unclear?
- Add --profile to bash completion
- podman-compose up is reporting that the folder is not empty
- 'podman-compose build' builds replicate images for each service in docker-compose.yaml that share a common image.
- 1.1.0 (and perhaps above) broke the use of Containerfiles HOT 1
- Error: unknown flag: --env HOT 1
- podman-compose should throw a readable error on too old python HOT 2
- All integration tests should be run automatically HOT 1
- Environment should not be set in build context HOT 2
- Detect case when port forwarding is used together with uid/gid mapping on Podman 3.4.x and issue warning HOT 4
- podman-compose up -d <container> starts other containers in the compose file
- lint checks in CI don't currently work properly.
- Release version 1.2.0 to EPEL 8 / EPEL 9 HOT 1
- Integration tests should not use network connectivity if not necessary
- Incorrect implementation of `include` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from podman-compose.