Running docker container through python API with specific ulimit
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Dear all, I don't know wether it is an issue or not, but I noticed a very strange behaviour when trying to set some limits whiler running a docker container.
I described the problem here:
https://stackoverflow.com/questions/54884874/running-docker-container-through-python-api-with-specific-ulimit
Here is a copy:
Now I want to create a container to run a dummy command inside an image following this simple documentation/tutorial: https://docker-py.readthedocs.io/en/stable/containers.html#container-objects
import docker
client = docker.from_env()
client.containers.run(shm_size='1g', ulimits=[docker.types.Ulimit(name='memlock', hard=-1), docker.types.Ulimit(name='stack', hard=67108864)], image='ubuntu:16.04', auto_remove=True, command='date')
Here is the result:
--------------------------------------------------------------------------- ContainerError Traceback (most recent call last) in () ----> 1 client.containers.run(shm_size='1g', ulimits=[docker.types.Ulimit(name='memlock', hard=-1), docker.types.Ulimit(name='stack', hard=67108864)], image='ubuntu:16.04', auto_remove=True, command='date')
~/anaconda3/lib/python3.7/site-packages/docker/models/containers.py in run(self, image, command, stdout, stderr, remove, **kwargs) 812 if exit_status != 0: 813 raise ContainerError( --> 814 container, exit_status, command, image, out 815 ) 816
Although the following command works perfectly:
docker run --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 --rm -t ubuntu:16.04 "date"
What is the problem in the combination of options that I used ?
Thank you in advance for your help
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 with the documented containers.run example and the supplied docker.types.Ulimit configuration, then reproduce the ContainerError using ubuntu:16.04. Compare it with the equivalent docker run command and determine why the Python API combination fails; done means the discrepancy is explained and the affected behavior is corrected or documented.
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
- 35/100