rm option loses some logs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Hi everyone,
Problem:
I've found a problem. When we are using docker run with option auto_remove. Somethimes we can skip some logs.
Example:
For example lets run some python code with a bug:
Let's use docker cli:
- without rm option
aleksandermangin@ubuntu ~/dev/src/docker-py (master) $ docker run python python -c "xxx"
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'xxx' is not defined
- with rm option
aleksandermangin@ubuntu ~/dev/src/docker-py (master) $ docker run python python -c "xxx"
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'xxx' is not defined
So looks like great.
Let's do the same staff with docker-py:
- without rm option
In [1]: import docker
In [3]: c = docker.from_env()
In [6]: c.containers.run('python', 'python -c "xxx"', stderr=True, stdout=True)
ContainerError: Command 'python -c "xxx"' in image 'python' returned non-zero exit status 1: b'Traceback (most recent call last):\n File "<string>", line 1, in <module>\nNameError: name \'xxx\' is not defined\n'
- with rm option
In [1]: import docker
In [2]: c = docker.from_env()
In [3]: c.containers.run('python', 'python -c "xxx"', stderr=True, stdout=True, auto_remove=True)
ContainerError: Command 'python -c "xxx"' in image 'python' returned non-zero exit status 1
So we lost a part of message with rm option!
Where is the problem?
https://github.com/docker/docker-py/blob/master/docker/models/containers.py#L826
Here we did two bad things:
- We changed the rules of logging. I think It's so surprising behaviour
- We changed the rules after running docker container. We are losing here a lot of messages.
How to fix it?
My pr will be soon
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in docker/models/containers.py around line 826, where the issue reports different error output when auto_remove is enabled. Reproduce the two containers.run examples with and without auto_remove and compare the complete error message; done means the auto-remove case preserves the logged failure details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100