Skip to content

Running multiple environments in parallel using same container failed with container name conflict error. #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
xeronm opened this issue Jan 17, 2025 · 0 comments

Comments

@xeronm
Copy link

xeronm commented Jan 17, 2025

Hi,

I've faced with the following problem.
I use two environment with postgres container.
When I run in parallel mode tox -p, only first environment that use container succeeded, the second fails with container name conflict error.

docker.errors.APIError: 409 Client Error for http+docker://localhost/v1.43/containers/create?name=db-tox-31039: Conflict ("Conflict. The container name "/db-tox-31039" is already in use by container "9e91cc7f480abcc9ac28a8f47eb4520a6de4db3811b8c706d4371d80330ae97e". You have to remove (or rename) that container to be able to reuse that name.")
  flake: OK ✔ in 8.25 seconds
  py39-dj42-sqlite: OK ✔ in 1 minute 5.1 seconds
  py310-dj42-sqlite: OK ✔ in 1 minute 11.35 seconds
  py39-dj42-sqlite: OK (65.10=setup[5.71]+cmd[3.62,52.08,1.10,1.23,1.35] seconds)
  py39-dj42-postgres: OK (81.13=setup[11.72]+cmd[67.23,0.74,0.76,0.68] seconds)
  py310-dj42-sqlite: OK (71.35=setup[7.10]+cmd[3.36,57.53,0.91,1.00,1.45] seconds)
  py310-dj42-postgres: FAIL code 2 (7.19 seconds)
  isort: OK (7.47=setup[5.58]+cmd[1.90] seconds)
  flake: OK (8.25=setup[5.71]+cmd[2.54] seconds)
  evaluation failed :( (81.48 seconds)

The problem is in

def runas_name(container_name: str, pid: Optional[int] = None) -> str:
    ...
    pid = pid or os.getpid()
    return f"{container_name}-tox-{pid}"

Could you consider using either thread Id instead process Id or concatenate {env_name} with process id?

def runas_name(container_name: str, pid: Optional[int] = None) -> str:
    ...
    pid = pid or threading.get_ident()
    return f"{container_name}-tox-{pid}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant