Docker container exits without response or warning
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Environment:
- Python: Python 3.8.10
- Docker: Docker version 20.10.14, build a224086
- docker (library): docker-5.0.3
Issue Description:
On running a program inside a container, initialized with 1g of mem_limit, the container exits without any response or warning, or error. I do understand that the program I am running can consume more than 1g in some cases but I need the container to exit with at least some output or status because the connection remains open even if the container has been exited which halts the whole process cycle.
Supporting Code:
# how am I creating the container:
container = self.docker_client.containers.run(
self.container_name,
detach=True,
stderr=True,
stdout=True,
tty=True,
mem_limit="1g",
runtime='runsc', # gVisor Runtime
)
# how amI executing the code:
docker_command = self.docker_client.api.exec_create(
self.container.id,
"python3 test.py",
)
output = self.docker_client.api.exec_start(
docker_command,
)
Image and Code:
Docker Image:
FROM python:3.7
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN useradd -ms /bin/bash guest
RUN ["chown", "-R", "guest:guest", "/usr/src/app"]
USER guest
Python code:
This is the code I tried to execute inside the docker container.
- NOTE: THE CODE IS PURPOSELY WRITTEN TO TEST THE MEMORY CONSUMPTION *
while True:
for i in range(0,100000000):
Gig = 1024*1024*1024*1024*2#A Gig multiplied by 2
a = 999999999999999999999 * (i * Gig)
a = a * i
print str(a)*2
Errors / Traceback:
I tried printing and logging but unfortunately, the docker connection never closes and I have to manually interrupt when I can notice a container exited using docker container ls -a.
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 by reproducing the issue with the shown containers.run, exec_create, and exec_start calls, using the stated memory limit and gVisor runtime. Check the container and exec exit state alongside returned output; done means the connection closes and exposes a useful status or message after the workload exits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100