B
B
bengur22021-01-20 15:15:02
WordPress
bengur2, 2021-01-20 15:15:02

Which docker-compose.yml is best for WordPress hosting?

Good afternoon.

I found two docker-compose.yml codes:

version: "3"
services:
        mysql:
            image: mariadb
            ports:
                - "3260:3260"
            volumes:
                - mysql_data:/var/lib/mysql
            environment:
                MYSQL_ROOT_PASSWORD: example

        wordpress:
          image: wordpress
          ports:
              - "2000:80"
          volumes:
              - mywebsite_data:/var/www/html
              - ./wp-content/themes/:/var/www/html/wp-content/themes
              - ./wp-content/plugins/:/var/www/html/wp-content/plugins
          environment:
              WORDPRESS_DB_PASSWORD: example
          depends_on:
              - mysql
          links:
              - mysql
volumes:
        mysql_data:
        mywebsite_data:

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}


Will they do the same job?
Which to choose?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
brizing, 2021-01-20
@bengur2

There is some code in the Docker documentation:
https://docs.docker.com/compose/wordpress/

S
Stanislav Makarov, 2021-01-20
@Nipheris

Do you need MariaDB or MySQL?
Do you need to separately map the web root and plugins with themes into the container?
Do you need to pass all the credentials to connect to the database through environment variables or just the password?
I think you should answer these questions yourself, based on your situation. If you can't compare and understand the difference yourself, why are you even using docker compose?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question