docker / docker/docker-py

healthcheck test silently ignored when of wrong type

Open
#2,529 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

Bug, affected versions:

  • docker-py: 4.1.0
  • docker-ce: 19.03.8
Summary

healtcheck['test'] is implicitly expected to be a str, and the API not only does not complain if it is a list, but just seemingly ignores it without any effect. The documentation is not very generous, it only mentions healthcheck has to be a dict.

How to reproduce:
from docker import from_env

containers = from_env().containers

args = ['alpine', ['sh']]
kwargs = {'tty': True, 'detach': True, 'healthcheck': {'test': 'true'}}

good = containers.run(*args, **kwargs)
assert 'Health' not in good.attrs['State']
good.reload()
assert 'Health' in good.attrs['State']

kwargs['healthcheck']['test'] = ['true']

bad = containers.run(*args, **kwargs)
assert 'Health' not in bad.attrs['State']
bad.reload()
assert 'Health' in bad.attrs['State']
Proposed fix
  1. assert healthcheck['test'] type is a str
  2. document healthcheck keys

When encountering this behavior I was still under the (wrong) impression that dockerfile HEALTHCHECK can be also defined as a list, just like CMD. So you might not consider this a bug and that's fine. If you do however, I will request a pull once I get some free time.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the containers.run reproduction in the issue, comparing string and list values for healthcheck['test']. Trace how the healthcheck argument is handled, then verify that an invalid list is rejected and that the documented healthcheck keys describe the accepted input.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.