Hi all,
I’m new to development and Docker so I apologise if this question is really basic. I looked through past topics and couldn’t find anything answering this specific question.
I need to set up multiple containers on localhost in order to be able to work on several clients’ WordPress projects at the same time. The docker-compose.yml file I use contains the below instructions, which work to create one localhost WordPress site on http://localhost:8000/, but if I try to create another installation, changing the port to any other number, e.g. “8001:80”, in the docker-compose.yml file, nothing appears on http://localhost:8001/.
Is it because I need to expose the new port? How can that be done in this docker-compose.yml file? Do I need to change the db host number as well? I’m sure this will seem obvious to most of you but I would really appreciate you pointing me in the right direction. Thanks so much.
version: ‘2’
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- “.:/var/www/html”
ports:
- “8000:80”
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data: