sábado, 11 de septiembre de 2021

How to use docker-compose to start your wordpress

If you are new using docker, fisrt we need to read the documentatión. And then continue reading.

The classic or common way is start ower server in local PC someTimes it is a nice choisse. Because the goal is met.

When we are using docker-compose all configs and  also all step to steps for to start an application . All this will be easy.

The rock star is the dockerizing.

Docker-compose to start your WordPress. Currently the best way for testing, running the applications is using docker The great advantage is that your application will be portable

1. Create the project!

mkdir docker-wp
cd docker-wp
touch docker-compose.yml

Now add the next script:

version: "3.9"
# container: db
    image: mysql:5.7
      - ./db_data:/var/lib/mysql
    restart: always
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

# container: wordpress
      - db
    image: wordpress:latest
      - ./wordpress_data:/var/www/html
      - "8000:80"
    restart: always
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
# container: adminer
    image: adminer
    restart: always
      - 8080:8080

2. Explain docker-compose.yml | Short description

version: [is the version of docker-compose format 2.x , 3.x]

services: there are the services from your application
Here we have (3) services called:

  1. db
  2. wordpress
  3. adminer

db Container

image: image of mysql with specific version 5.7

volumes: db_data is the directory accessible by us (this folder will be generate the first time) and also is where we save the data mysql

restart: the parameter restart container ever. Useful when the service crashed or goes down

environment: these variables are accepted by mysql image and usefull for automatize the creation of 1 or multiple databases



Resource: https://github.com/enlacee/docker-wp

No hay comentarios.:

Publicar un comentario