2016.05.17 Docker WordPress - GlenKPeterson/One-off_Examples GitHub Wiki

How To Run Wordpress in Docker

After spending more than half a day trying to run WordPress in NGINX, then Apache, I took 15 minutes and figured out how to run it in Docker. Replace the word whatever below with something relevant to your project.

# You probably want to manually replace both of these environment
# variables with something appropriate to your project.
PROJECT_NAME=whatever
PROJECT_DIR=/home/myName/whatever

docker pull mysql

docker pull wordpress

docker run \
    -d \
    -e MYSQL_ROOT_PASSWORD=my-secret-pw \
    --name ${PROJECT_NAME}-mysql \
    mysql

docker run \
    -d \
    --link ${PROJECT_NAME}-mysql:mysql \
    --name ${PROJECT_NAME}-wordpress \
    -p 80:80 \
    -v ${PROJECT_DIR}/www/html:/var/www/html \
    wordpress

If you run into upload size limits, add the file ${PROJECT_DIR}/www/html/php.ini to your host OS with the following:

[PHP]
; http://git.php.net/?p=php-src.git;a=blob_plain;f=php.ini-production;hb=HEAD

; Maximum allowed size for uploaded files.
; http://php.net/manual/en/ini.core.php#ini.upload-max-filesize
upload_max_filesize = 20M