Maintain a running container
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
I am trying to start/run a container and pass commands consecutively. However, as soon as I run the container, it exits and no other exec_run() commands go through. The specific error message is as follows:
docker.errors.APIError: 409 Client Error for http+docker://localnpipe/v1.43/containers/{id}/exec: Conflict ("Container {id} is not running")
The code is as follows:
import docker
client = docker.from_env()
image = client.images.pull(docker.io/{}/{})
container = client.containers.run(image = image.id, detach = True, command = 'echo starting container', tty = True, stdin_open = true)
container.exec_run("echo execute command")
I am running version 6.1.3 on Python 3.11.5.
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 provided docker-py 6.1.3 example and inspect the container lifecycle around containers.run and exec_run. Reproduce it with Python 3.11.5, then verify whether consecutive exec_run calls work as expected or whether the behavior needs to be documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100