Spin up a WordPress Instance with Docker/Docker-Compose

Ever needed a fast way to spin up a fresh instance of WordPress to try something out or to have your personal local dev environment?

You have Docker & Docker-Compose installed on your machine?

Excellent – just do the following

  • Create a new directory, eg. “wp-dev-docker
  • Inside it – create a new file called “docker-compose.yml” with the following content (be sure to define your own WORDPRESS_DB_PASSWORD!)
version: '3.7'

    image: wordpress
    restart: always
      - 8080:80
      WORDPRESS_DB_PASSWORD: mySampleAndSecurePwd123
    image: mysql:5.7
    restart: always
      MYSQL_ROOT_PASSWORD: mySampleAndSecurePwd123
  • Open your terminal inside your previously created directory and execute
> docker-compose up -d

Further usefull Docker commands:

> docker-compose logs -f   # shows log output of both wordpress+mysql containers
> docker-compose stop      # stops the containers without removing them
> docker-compose down      # stops the containers and removes them
> docker-compose images    # shows list of both containers 
> docker volume ls         # shows a list of your current volumes
> docker volume inspect abexdxdddd # shows meta info about a specific volume
> docker volume rm abexdxdddd        # removes volume with given name - CAREFULL! this is where the data of your containers is stored

Leave a Reply

Your email address will not be published.