Jump to content

Processwire Docker Container and MySQL


HenroRitchie
 Share

Recommended Posts

Hi

I have attempted to install Processwire inside a Docker container. This works well, however, during the setup Processwire needs to connect to the MySQL database. This is on the same server but in another docker instance. At the moment the error I am receiving is:  SQLSTATE[HY000] [2002] No such file or directory. 

How do I solve this error?

Link to comment
Share on other sites

I answered you on IRC, but then you quit. I will just share my docker-compose.yml in case you want to try it out (for local development):

version: '3.0'

services:
  caddy:
    image: abiosoft/caddy:latest
    volumes:
      - /path/to/local/directory/Caddyfile:/etc/Caddyfile
      - /path/to/local/directory/processwire:/srv
    ports:
      - "2015:2015"
    links:
      - mariadb
      - php-fpm
    restart: always

  mariadb:
    image: bianjp/mariadb-alpine:latest
    environment:
      MYSQL_DATABASE: mydb
      MYSQL_USER: mydb
      MYSQL_PASSWORD: mypass
      MYSQL_ROOT_PASSWORD: mypass
    volumes:
      - /path/to/local/directory/mariadbdata:/var/lib/mysql
      - /path/to/local/directory/override.cnf:/etc/mysql/conf.d/override.cnf    
    ports:
      - "3306:3306"
    restart: always

  php-fpm:
    image: wodby/php:latest
    environment:
      PHP_FPM_USER: wodby
      PHP_FPM_GROUP: wodby
      PHP_MAX_EXECUTION_TIME: 180
      PHP_MEMORY_LIMIT: 4096M
      PHP_UPLOAD_MAX_FILESIZE: 4096M
      PHP_POST_MAX_SIZE: 4096M
      PHP_MAX_INPUT_TIME: 180
      PHP_MAX_INPUT_VARS: 10000
    volumes:
      - /path/to/local/directory/processwire:/srv
    restart: always

I use that separate wodby php, because I can define the running user/group to be "wodby", which has ID 1000, so I don't have to fiddle with my local file ownership (same ID as my host user).

As you see, I have PW's files on local disk and also the database + Caddy and MariaDB configs.

 

  • Like 2
Link to comment
Share on other sites

Hi

Thank you for the reply and the information. Apologies for only replying now. As both PW and the database are running in separate containers I struggled to link the two together.

On IRC I discussed the issue with user buovjaga (which might be your IRC username?). During that discussion, the user posted two links and this link - https://github.com/davidk132/processwire-docker-compose provided the answer.

The method with which you link the database container to the PW container from the PW setup is the important part. The database ip/url should be the name of the database container service.

Other than that I struggled with a faulty docker container and MySQL. 

Eventually the I used the following which works:

  • PW docker - suzel/docker-processwire
  • Database - Official MariaDB
  • localhost should be replaced with the MariaDB docker container service ID - in my case mdb1
  • Below the docker-compose file:
version: '2'

services:
  mdb1:
    image: mariadb:latest
    volumes:
     - /path/to/local/directory/mysql_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ***
      MYSQL_DATABASE: ***
      MYSQL_USER: ***
      MYSQL_PASSWORD: ***

  pw1:
    depends_on:
      - mdb1
    image: suzel/docker-processwire
    restart: always
    volumes:
      - volume:/var/www/html
      #- ./config:/usr/local/etc/php
    ports:
      - "80:80"

volumes:
  procw1_data:

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...