HUB
Sign inSign up

flyinghippo/wordpress

By flyinghippo

•Updated over 7 years ago

Image
1

2.0K

flyinghippo/wordpress repository overview

⁠https://github.com/parleer/docker-wordpress⁠

⁠What is this?

A docker image that can be used for WordPress development.

⁠Why?

The official wordpress docker image doesn't work well for local development. If you try to map your source folder to /var/www/html so that you can edit and run your WordPress site, it will override your wp-config.php settings, which will likely end up in you saving DB_HOST, DB_NAME, DB_USER, and DB_PASSWORD values in your git repo.

⁠To use this image

⁠Step 1:

Setup your wp-config.php to pull DB_HOST, DB_NAME, DB_USER, and DB_PASSWORD from the environment:

define("DB_HOST",     getenv("WORDPRESS_DB_HOST"));
define("DB_NAME",     getenv("WORDPRESS_DB_NAME"));
define("DB_USER",     getenv("WORDPRESS_DB_USER"));
define("DB_PASSWORD", getenv("WORDPRESS_DB_PASSWORD"));
⁠Step 2:

Create a launch script that will run this container, and mount your local folder as the source:

echo "Starting wordpress container"
docker run \
	--name www-website-com \
	-v "$(pwd)/web":/var/www/html \
	-e WORDPRESS_DB_HOST=host.docker.internal \
	-e WORDPRESS_DB_USER=root \
	-e WORDPRESS_DB_PASSWORD=root \
	-e WORDPRESS_DB_NAME=www-website-com \
	-P \
	-d flyinghippo/wordpress
⁠Step 3:

Visit your docker hosted website in a browser:

Here's a bash function that makes it easy to launch your site on MacOS.

dock () 
{ 
    command="docker ps --format='{{.Names}}' | grep -m 1 '$1'";
    site=$(eval $command);
    if [ -n "$site" ]; then
        open "http://localhost:$(docker port $site | cut -d':' -f2)";
    else
        echo 'no matching sites found.';
    fi
}

Then you can run:

dock website

and it will automatically open your default web browser to the docker port to the docker container that matches "website"

Tag summary
Recent tags
Content type
Image
Digest
sha256:9f0a9e293…
Size
166.5 MB
Last updated
over 7 years ago
docker pull flyinghippo/wordpress:latest