Deploy WordPress, MySQL, phpMyAdmin, Elasticsearch and Kibana with docker-compose

Assuming you already have Docker installed. Create a docker-compose.yml file with following codes:

version: "3"
services:
  #MySQL Database image
  db:
    image: mysql
    restart: always
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: <root_password>
      MYSQL_DATABASE: wpdb
      MYSQL_USER: admin
      MYSQL_PASSWORD: <admin_password>
    volumes:
      - ./data/mysql:/var/lib/mysql

  #WordPress image based on Apache
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    restart: always
    ports:
      - "8000:80"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: admin
      WORDPRESS_DB_PASSWORD: <wpdb_password>
      WORDPRESS_DB_NAME: wpdb
    volumes:
      ["./:/var/www/html"]

  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - '8070:80'
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: <root_password>

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
    container_name: sem_elasticsearch
    restart: always
    ports:
      - "9200:9200"

    # restart: on-failure
    environment:
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms256m -Xmx256m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./data/elasticsearch:/usr/share/elasticsearch/data
    logging:
        driver: "json-file"
        options:
            max-size: "10k"
            max-file: "10"

  kibana:
    image: docker.elastic.co/kibana/kibana:7.9.3
    container_name: sem_kibana
    restart: always
    environment:
      - "ELASTICSEARCH_URL=http://elasticsearch:9200"
      - "SERVER_NAME=127.0.0.1"
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch

volumes
  mysql: {}