docker-compose up ができない(buildできない)


docker-compose up --build

でビルドしようとしたが下記のようなエラーが出た。

ERROR: for phpmyadmin  Cannot create container for service phpmyadmin: Conflict. The container name "/phpmyadmin" is already in use by container "〇〇". You have to remove (or rename) that container to be able to reuse that name.

Creating mysql       ... 〇〇". You have to remove (or rename) that container to be able to reuse that name.

ERROR: for mysql  Cannot create container for service db: Conflict. The container name "/mysql" is already in use by container "〇〇". You have to remove (or rename) that container to be able to reuse that name.

ERROR: for phpmyadmin  Cannot create container for service phpmyadmin: Conflict. The container name "/phpmyadmin" is already in use by container "〇〇". You have to remove (or rename) that container to be able to reuse that name.

ERROR: for app  Cannot create container for service app: Conflict. The container name "/laravel" is already in use by container "b035ca2af11bfd74a1b04d341cd1ac0075b4301bdb484a598167f1db2b869b1a". You have to remove (or rename) that container to be able to reuse that name.

ERROR: for db  Cannot create container for service db: Conflict. The container name "/mysql" is already in use by container "〇〇". You have to remove (or rename) that container to be able to reuse that name.
ERROR: Encountered errors while bringing up the project.

既存のコンテナ名と重複してしまうためビルドできないということなので

docker rm $(docker ps -aq) --force

でコンテナを一掃してから、再度ビルドするとうまくいきました