Skip to content

Instantly share code, notes, and snippets.

@wzulfikar
Last active December 4, 2020 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wzulfikar/dbe9aba875763bd98fd2f5e7b5e1ab6b to your computer and use it in GitHub Desktop.
Save wzulfikar/dbe9aba875763bd98fd2f5e7b5e1ab6b to your computer and use it in GitHub Desktop.
Setup wordpress using docker. Tested on Ubuntu.
#!/bin/sh
# File: /opt/wordpress/run.sh
APP_NAME=acme-blog
WORKDIR=/opt/wordpress
if [ ! -f "uploads.ini" ]; then
touch ${WORKDIR}/uploads.ini
fi
docker run -d --restart unless-stopped --env-file ${WORKDIR}/.env --name ${APP_NAME} \
-v ${WORKDIR}/wp-content:/var/www/html/wp-content \
-v ${WORKDIR}/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini \
wordpress:latest
# If docker has no write access to wp-content, wordpress will ask you for FTP details
# when you want to install plugins. This command will allow docker to have write access
# to wp-content.
docker exec ${app_name} chown -R www-data:www-data /var/www/html/wp-content/
@wzulfikar
Copy link
Author

The script will not expose wordpress container to the world.

You may want to consider setting up nginx with automated https using docker. See: https://gist.github.com/wzulfikar/957917c8ad84a6047bdb0831215daa51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment