Compose: service_run_+1

Created on 31 Mar 2017  ·  3Comments  ·  Source: docker/compose

I have a two cronjob for run php service in same time.

Only one run command execute correctly

Cannot create container for service php: Conflict. The container name "/folder_php_run_1" is already in use by container {hashhere}. You have to remove (or rename) that container to be able to reuse that name.
Command exited with non-zero status 1
arerun kinbug

All 3 comments

That probably means the container is being created between the time we check for availability and the time we actually issue the create command. A solution would be to run those two jobs at slightly different times (a 5 second interval would likely be enough)

I encounter this as well by running docker-compose up foo bar & docker-compose up baz bar programmatically in different tmux tabs. It seems like if creation fails, it should re-run the check and attempt to (wait and) attach.

Very simple reproduction case:

➤ cat docker-compose.yml 
version: "2.2"
services:
  test:
    image: alpine

➤ docker-compose run --rm test true
Creating network "test_default" with the default driver

➤ docker-compose run --rm test docker-compose run --rm test true &; docker-compose run --rm test true
ERROR: Cannot create container for service test: Conflict. The container name "/test_test_run_1" is already in use by container "76db8705667961966468d66d0667417862ad6edb3fb4c09b95a8ebab4ec36bf8". You have to remove (or rename) that container to be able to reuse that name.
Job 4, 'docker-compose run --rm test do…' has ended

In my case the problem is a CI that triggers parallel jobs based on its internal schedule. It's very sad to have to hack that scheduling just because of this.

Was this page helpful?
0 / 5 - 0 ratings