Goglides Dev 🌱

Cover image for Compose and dockerize WordPress with MySQL - Quickstart
Roshan Thapa
Roshan Thapa

Posted on • Updated on

Compose and dockerize WordPress with MySQL - Quickstart

Define the project

1. Create an empty project directory.

For example, if you named your directory my_wordpress:
$ mkdir my_wordpress

2. Enter your project directory.

$ cd my_wordpress

3.Create a docker-compose.yml file that starts your WordPress.

version: '3'

    image: 'mysql:5.7'
    restart: always
      MYSQL_ROOT_PASSWORD: wordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

    image: wordpress
      - mysql
      - 'mysql:mysql'
      - '8080:80'
    restart: always
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress

Enter fullscreen mode Exit fullscreen mode

3. Now build the project

Now, run $ docker compose up from your project directory.
This runs docker compose up in detached mode, pulls the needed Docker images, and starts the wordpress and database containers.

4. Bring up WordPress in a web browser

At this point, WordPress should be running on port 8080 which we define on docker-compose.yml

Final Result:

Image description

Top comments (0)