Skip to content

Instantly share code, notes, and snippets.

@dnburgess
Created December 8, 2020 16:06
Show Gist options
  • Save dnburgess/948d9c61199392db74742dc1aa99cea2 to your computer and use it in GitHub Desktop.
Save dnburgess/948d9c61199392db74742dc1aa99cea2 to your computer and use it in GitHub Desktop.
DB Tech WordPress for Pi Home Server
version: '2.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 84:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- /srv/dev-disk-by-label-Files/Config/WordPress:/var/www/html
links:
- db:db
db:
image: yobasystems/alpine-mariadb:latest
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- /srv/dev-disk-by-label-Files/Databases/WordPress:/var/lib/mysql
@sarvesh-pugo
Copy link

Hi, thank you for the above.

However, when i go the wordpress port, it says, cannot establish connection to database. Any idea why is that?

Thanks.

Regards,

@bashsyr
Copy link

bashsyr commented May 10, 2021

Same Here

@phamleduy04
Copy link

@sarvesh-pugo @bashsyr try to use jc21/mariadb-aria:latest as database image. I changed to that and it fixed

@ErikUden
Copy link

Any updates on this? @phamleduy04's solution no longer works (tested on x86 based system), am getting the "Error establishing a database connection" error.
Adding

volumes:
  wordpress:
  db:

to the bottom, also does nothing.

@phamleduy04
Copy link

So I tried this on x86 based system and confirm it worked

version: '3.6'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 84:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - ./wp:/var/www/html
    links:
      - db:db

  db:
    image: docker.io/bitnami/mariadb:10.7
    environment:
      MARIADB_ROOT_PASSWORD: examplepass
      MARIADB_USER: exampleuser
      MARIADB_PASSWORD: examplepass
      MARIADB_DATABASE: exampledb
    volumes:
      - './mariadb_data:/bitnami/mariadb'
    healthcheck:
      test: ['CMD', '/opt/bitnami/scripts/mariadb/healthcheck.sh']
      interval: 15s
      timeout: 5s
      retries: 6

Volumes start with ./ means it will create a folder in the folder where the docker-compose.yml is stored. If you use Portainer or something else you should specify the full path, or use docker volumes.

Check the MariaDB logs, I got some permission errors like this
mkdir: cannot create directory '/bitnami/mariadb': Permission denied
It can be fixed by using this command

sudo chown -R 1001:1001 <mariadb_folder>

@msdosfx
Copy link

msdosfx commented Oct 10, 2022

What do I put for the volumes: variable if I am not using Open Media Vault. Do I create a volume in portainer? I am trying to follow along from the youtube tutorial. Please explain as if you are explaining to someone who has no experience navigating file systems in linux/raspbian.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment