I have been able to run wordpress with mysql and phpmyadmin all together with Docker.
The problem is that I am using gulp with my themes, plugins and so need to implement the browsersync between my host files and my docker container.
I have been looking online and found out only one example really close to my case: Browsersync within a Docker container.
So I tried to follow his docker-compose.yml file by adding a new docker container node with a personal Dockerfile.
Here are my docker-compose and Dockerfile (node) files:
docker-compose.yml:
version: '3'
services:
wordpress:
image: wordpress:latest
build:
dockerfile: Dockerfile
context: ./
container_name: wordpress
links:
- mysql
environment:
- WORDPRESS_DB_USER=user
- WORDPRESS_DB_NAME=db_name
- WORDPRESS_TABLE_PREFIX=prefix_
- WORDPRESS_DB_PASSWORD=password
- WORDPRESS_DB_HOST=mysql:3306
restart: unless-stopped
ports:
- 80:80
volumes:
- file_data:/var/www/html/Project
networks:
- back
mysql:
image: mysql:latest
container_name: mysql
command: mysqld --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=db_name
- MYSQL_HOST=localhost
- MYSQL_PASSWORD=password
restart: unless-stopped
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
- ./config/database/db.sql:/docker-entrypoint-initdb.d/db.sql
networks:
- back
phpmyadmin:
depends_on:
- mysql
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
restart: unless-stopped
ports:
- 8088:80
environment:
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD: password
networks:
- back
node:
restart: unless-stopped
image: node:latest
container_name: nodejs
depends_on:
- wordpress
volumes:
- file_data:/usr/src/app
build:
dockerfile: Dockerfile
context: ./Gulp
ports:
- 3000:3000
- 3001:3001
networks:
back: {}
volumes:
db_data: {}
file_data: {}
Dockerfile:
FROM node:latest
# Create app directory
WORKDIR /usr/src/app/Gulp
# Install app dependencies
COPY Gulp Project ../
RUN npm rebuild && npm install && npm install gulp@next && npm install --global gulp-cli
EXPOSE 8080
CMD [ "gulp" ]
But the mean problem is whatever my Dockerfile looks like, even empty with only FROM node:latest
, when I do docker build
of my Dockerfile, I get an exited container, but when I create a docker container with Kitematic app of node, I get it Up properly. What am I doing wrong here ? And does my configuration looks good except my main issue ?
Thanks for your help.