お世話になります。
いま、DockerでRailsやPHPの環境を作成する勉強をしています。
とりあえずはRails6.02+MySQL8.0は環境を作れました。
さて愚問です!
このDockerへPHP+MySQLの環境も作ることできますか?
PCのOSでは1つのPortしか使えませんね
Railsで使っているMySQLはPHPでも使えるのでしょうか?
この場合Portによる競合はエラーとして出ませんでしたがcontainerでの競合が出てしまいました。
docker.compose.yml
1version: '3' 2 3services: 4 php: 5 container_name: php 6 build: ./docker/php 7 volumes: 8 - ./server:/var/www 9 10 nginx: 11 image: nginx 12 container_name: nginx 13 ports: 14 - 80:80 15 volumes: 16 - ./server:/var/www 17 - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf 18 depends_on: 19 - php 20 21 db: 22 image: mysql:5.7 23 container_name: db-host 24 environment: 25 MYSQL_ROOT_PASSWORD: root 26 MYSQL_DATABASE: database 27 MYSQL_USER: docker 28 MYSQL_PASSWORD: docker 29 TZ: 'Asia/Tokyo' 30 command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci 31 volumes: 32 - ./docker/db/data:/var/lib/mysql 33 - ./docker/db/my.cnf:/etc/mysql/conf.d/my.cnf 34 - ./docker/db/sql:/docker-entrypoint-initdb.d 35 ports: 36 - 3306:3306
$ docker-compose up -d Creating php ... error Creating db-host ... ERROR: for php Cannot create container for service php: Conflict. The container name "/php" is already in use by container "c8ac2f33b938ddc4a616ebc339aca7b1b2db3ca77b7939b5b86b1391a2a59406". You have to remove (or rename) that container Creating db-host ... error ERROR: for db-host Cannot create container for service db: Conflict. The container name "/db-host" is already in use by container "ab0380e7d9b15e98b7ee5e2e4e883b2cea5324aa5920a2c0123d8c13df062b89". You have to remove (or rename) that container to be able to reuse that name. ERROR: for php Cannot create container for service php: Conflict. The container name "/php" is already in use by container "c8ac2f33b938ddc4a616ebc339aca7b1b2db3ca77b7939b5b86b1391a2a59406". 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 "/db-host" is already in use by container "ab0380e7d9b15e98b7ee5e2e4e883b2cea5324aa5920a2c0123d8c13df062b89". You have to remove (or rename) that container to be able to reuse that name.
削除(名前の変更の仕方)の仕方がわかりません
よろしくご指導ください
あなたの回答
tips
プレビュー