docker / docker/docker-py

Maintain a running container

Open
#3,214 3 comments 1 reaction 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

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.