Monday 22 July 2019

Running .yml file in Docker to build WordPress application along with MySQL DB

WordPress is sample application made available as image in Docker hub/repository. To build this application with docker process it is also required DB to associate.

Following is the sample yml file with configuration details to be used in docker to build wordpress application up and running.

docker-compose.yml application:

version: '3'
services:
  wordpress:
    image: wordpress:latest # https://hub.docker.com/_/wordpress/
    ports:
      - 8081:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_NAME: govardhansql
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: abc123
    depends_on:
      - db
    links:
      - db

  db:
    image: mysql:latest # https://hub.docker.com/_/mysql/ - or mariadb https://hub.docker.com/_/mariadb

    command: [
        '--default_authentication_plugin=mysql_native_password',
        '--character-set-server=utf8mb4',
        '--collation-server=utf8mb4_unicode_ci'
    ]
    environment:
      MYSQL_DATABASE: govardhansql
      MYSQL_ROOT_PASSWORD: abc123


This file is located in my local machine with the path: "C:\Govardhan\YYYY\DevOps\Docker\wordpress"execute this .yml file from docker with following commands.
first open the cmd prompt or windows powershell.

CD C:\Govardhan\YYYY\DevOps\Docker\wordpress
docker-compose up

following are screenshots for the reference.


later use the url as "http:\\localhost:8081" to view the wordpress application.

Hurry!!!! We have build the wordpress application in the docker container in very quickly with the power of Docker.

No comments:

Post a Comment