[Docker] Build a Wordpress environment locally (Win, Mac) quickly

Install Docker Desktop on your local PC

https://www.docker.com/products/docker-desktop Please execute the download according to your environment (win, mac).

Check if it is installed safely with the following command

docker -v

You now have Docker Engine on your local machine.

So, if you don't start it, it's meaningless, so please start Docker. Probably if there is a whale icon somewhere, it is running.

Always keep in mind that working with Docker is ** an event in a virtual environment called Docker Engine **.

** "The environment is not built on the local host (PC), it is built on the Docker host (Engine)" **

Install python

e? python? Is there something wrong? Many people would have thought. I understand your feelings. But let's keep that feeling in our hearts. For the time being, to explain briefly, After this, you will also install a tool that assists Docker operation, That's a tool made in Python. Its name is ** "Docker Comopose" ** Python is quick to install it easily. ** Install "python3" and "python3-pip" ** respectively. https://www.python.org/

Check if it is installed safely with the following command

python3 -V

Install Docker Compose

So let's introduce an assistant tool for Docker operation.

pip3 install docker-compose

Check if it is installed safely with the following command

docker-compose --version

Create a working directory

Create it anywhere on your local PC and move to that directory. This time, let's call it "wp_test". It can be a command, manual with GUI, or whatever.

mkdir ~/wp_test
cd ~/wp_test

Create docker-compose.yml

What is this? I think it feels like that. As the name suggests, it is ** a Docker compose configuration file written in YAML format **. For the time being, create and save with the following contents with an editor, and place it in the corresponding directory created earlier.

docker-compose.yml


version: "3"

services:
  wordpress-db:
    image: mysql:5.7
    networks:
      - wordpressnet
    volumes:
      - wordpress_db_volume:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: myrootpassword
      MYSQL_DATABASE: wordpressdb
      MYSQL_USER: wordpressuser
      MYSQL_PASSWORD: wordpresspass

  wordpress-app:
    depends_on:
      - wordpress-db
    image: wordpress
    networks:
      - wordpressnet
    ports:
      - 8080:80
    restart: always
    environment:
      WORDPRESS_DB_HOST: wordpress-db
      WORDPRESS_DB_NAME: wordpressdb
      WORDPRESS_DB_USER: wordpressuser
      WORDPRESS_DB_PASSWORD: wordpresspass

networks:
  wordpressnet:

volumes:
  wordpress_db_volume:

Start a container with Docker Compose

Let's start the container with this setting for the time being. Be sure to run it in the directory where docker-compose.yml is located.

cd ~/wp_test
docker-compose up -d

Confirm startup

http://localhost:8080/

You should see the initial Wordpress installation screen. screenshot-localhost_8080-2021.01.12-17_07_57.png

Confirmation of container startup with command

docker-compose ps

You should see the container you are running.

Stop and destroy the container

docker-compose down

Finally

You may hear a voice saying, "Hey, you can't recover the hints by running like this!" Time is also time, so this time it's up to here. For the time being, try setting up Wordpress in this state and play around with it. Then, various problems will come up. Then see you again.

Recommended Posts

[Docker] Build a Wordpress environment locally (Win, Mac) quickly
Build a WordPress development environment quickly with Docker
Build a Node.js environment with Docker
Build a PureScript development environment with Docker
Build a WAS execution environment from Docker
Build a Java development environment on Mac
Build a JMeter environment on your Mac
Build a simple Docker + Django development environment
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Build a development environment for Docker + Rails6 + Postgresql
Build a Laravel / Docker environment with VSCode devcontainer
Build a simple Docker Compose + Django development environment
[Win10] Build a JSF development environment with NetBeans
Build a development environment for Docker, java, vscode
Easily build a Vue.js environment with Docker + Vue CLI
[Note] Build a Python3 environment with Docker in EC2
Build WordPress environment with Docker (Local) and AWS (Production)
Try to build a Java development environment using Docker
[2021] Build a Docker + Vagrant environment for using React / TypeScript
Build docker environment with WSL
Ruby ① Build a Windows environment
Build a CentOS 8 virtual environment on your Mac with VirtualBox
Build a Node-RED environment with Docker to move and understand
Create a Vue3 environment with Docker!
Build Couchbase local environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Prepare a transcendentally simple PHP & Apache environment on Mac with Docker
Build a browser test environment using Capybara in the Docker development environment
Build Java development environment (for Mac)
Build a XAMPP environment on Ubuntu
Build a development environment for Django + MySQL + nginx with Docker Compose
Set up a Wordpress Docker environment without using the Worpdress image
Build Unity development environment on docker
I tried to build a laravel operating environment while remembering Docker
Build docker + laravel environment with laradock
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Creating a java web application development environment with docker for mac part1
I tried to build a Firebase application development environment with Docker in 2020
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Create a java web application development environment with docker for mac part2
Laravel development environment construction with Docker (Mac)
Create a MySQL environment with Docker from 0-> 1
Build Redmine code reading environment on Docker
Build Cakephp environment from docker installation Ubuntu
Build Apache + Tomcat + Pebble locally on Mac
[Docker] Build Jupyter Lab execution environment with Docker
Build an environment with Docker on AWS
Build by specifying docker as a file
Build an Ultra96v2 development environment on Docker 1
Build TensorFlow operation check environment with Docker
How to build Rails 6 environment with Docker
Build a development environment to create Ruby on Jets + React apps with Docker
[Memo] Create a CentOS 8 environment easily with Docker