Compose: service_run_+1

作成日 2017年03月31日  ·  3コメント  ·  ソース: docker/compose

同時にrun phpサービスの 2 つの cronjob があります。

1 つのrunコマンドのみが正しく実行されます

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

全てのコメント3件

これはおそらく、可用性を確認してから実際にcreateコマンドを発行するまでの間にコンテナーが作成されていることを意味します。 解決策は、これらの 2 つのジョブをわずかに異なる時間に実行することです (5 秒間隔で十分です)。

docker-compose up foo bardocker-compose up baz barを異なる tmux タブでプログラムで実行すると、これにも遭遇します。 作成に失敗した場合は、チェックを再実行して (待機して) アタッチする必要があるようです。

非常にシンプルな再現ケース:

➤ 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

私の場合、問題は内部スケジュールに基づいて並列ジョブをトリガーする CI です。 このためだけにそのスケジュールをハックしなければならないのは非常に悲しいことです。

このページは役に立ちましたか?
0 / 5 - 0 評価