I am trying to set up a wordpress instance using docker compose. I want the wordpress container to have an IP address on my internal network unique from the host IP address. But I want the wordpress container and the mysql container to communicate over a bridge network. I am unable to build a yaml file that will do that. I can however, give the mysql container an IP address on my network and that works fine. How would I edit this yaml file to have wordpress and mysql communicate via a bridge network?
Is it even possible for a container to be on a vlan and a bridge network at the same time? Thanks in advance
version: '3.8'
services:
# Database
db:
image: mysql:latest
volumes:
- ./database:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 1234567
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
wordpressvlan:
ipv4_address: 192.168.1.7
# Wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- '80:80'
restart: always
volumes: ['./:/var/www/html']
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
networks:
wordpressvlan:
ipv4_address: 192.168.1.6
networks:
wordpressvlan:
name: wordpressvlan
driver: macvlan
driver_opts:
parent: ens1
ipam:
config:
- subnet: "192.168.0.0/24"
gateway: "192.168.1.1"
volumes:
database3: