Hello,
I am new to docker and have been able to run WordPress using docker-compose.yml file. But the problem is, I want to install another WordPress and run 2 or more WordPress instance at the same time and it shows the error as below:
zoynul@zoynul:~/www/cutekid$ sudo docker-compose up
Starting cutekid_db_1 ... error
ERROR: for cutekid_db_1 Cannot start service db: OCI runtime create failed: container with id exists: 4e67f6f258bd04c62efe790c7508fedd5fee4d299078c68637f8c75cb9c4cad2: unknown
ERROR: for db Cannot start service db: OCI runtime create failed: container with id exists: 4e67f6f258bd04c62efe790c7508fedd5fee4d299078c68637f8c75cb9c4cad2: unknown
ERROR: Encountered errors while bringing up the project.
zoynul@zoynul:~/www/cutekid$
docker-compose.yml that runs fine:
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- back
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 8080:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: somewordpress
networks:
- back
wordpress:
depends_on:
- db
image: wordpress:latest
# build:
# context: .
# dockerfile: ./build/Dockerfile
ports:
- "80:80"
restart: always
volumes:
# - .:/var/www/html
- ./wp-content:/var/www/html/wp-content
# - ./wp-config.php:/var/www/html/wp-config.php
environment:
# WORDPRESS_TABLE_PREFIX: ck_
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- back
networks:
back:
volumes:
db_data: {}
But this one generates the error:
version: '3.3'
services:
db:
image: mysql:5.7
# ports: 8081:3306
volumes:
- ./mysql:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- back
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 8082:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: somewordpress
networks:
- back
wordpress:
depends_on:
- db
image: wordpress:latest
# build:
# context: .
# dockerfile: ./build/Dockerfile
ports:
- 8083:90
restart: always
volumes:
# - .:/var/www/html
- ./wp-content:/var/www/html/wp-content
# - ./wp-config.php:/var/www/html/wp-config.php
environment:
# WORDPRESS_TABLE_PREFIX: ck_
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- back
networks:
back:
volumes:
db_data: {}
Any help is highly appreciated.
Thanks