1

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.

jardindeden
  • 125
  • 1
  • 12

1 Answers1

0

On your node docker file you need to change the port from 8080

EXPOSE 3000    
EXPOSE 3001
Clayton Harbich
  • 505
  • 1
  • 7
  • 16
  • Yes I am trying to build an image and then run it with docker-compose. But when I do docker-compose, all containers are up, except node. So I am trying to just run it alone first. I realised that even to do `docker run` command from the image node:latest is not even working for me.. What is wrong there ? the image or my docker run command ? `docker run -d node` – jardindeden Nov 14 '18 at 14:44
  • Sorry I didn't understand your question. What are you wanting the "gulp" command to do? Does that run your project? – Clayton Harbich Nov 14 '18 at 15:44
  • Ok I will add my gulpfile to explain. But to resume, I am using gulp to update my php, js and css of my theme and plugin by watching them using gulp browsersync. – jardindeden Nov 15 '18 at 10:06
  • @jardindeden Updated again. Did this help? – Clayton Harbich Nov 20 '18 at 17:05