Skip to content

The whole idea was to make starting new (or not new) WordPress project as easy as possible. Wordpress in Docker is a set of files to easily run WordPress in an isolated environment built with Docker containers.

Notifications You must be signed in to change notification settings

S-PRO/WordPress-In-Docker

Repository files navigation

Wordpress in Docker

Wordpress in Docker

The whole idea was to make starting new (or not new) WordPress project as easy as possible. Wordpress in Docker is a set of files to easily run WordPress in an isolated environment built with Docker containers. If you ever need something improved, added, or bugfixed, do not hesitate contacting me at [email protected].

What is inside:

Installation

Case 1: Setup new project

docker-compose up starts everything you require for new project. Once up, you'll get ready WordPress website on http://localhost:8000 and phpMyAdmin running on http://localhost:8001.
Note: Once you login in WordPress admin I highly recommend you to update WordPress and all plugins to latest versions if any available.

WordPress is the latest official 4.8 version extended with following:

  • Included Bones theme.
  • Included some essential, but not activated, plugins (Advanced Contact Fields, Contact Form 7, WP Mail SMTP, WP Migrate DB). Please let me know if you need more.
  • Included .gitignore file.
  • Removed all default themes and plugins.

Case 2: Setup existing project which was not under docker previously

Tricky part starts when you already have a project and want to start it and not default wordpress installation. To achieve this, do the following (the easiest way):

  • Replace db_dump.sql file with your database dump file. USE `wordpress`; must exist in your file!!! Otherwise docker has no idea where to import this dump. If not there, please add this row at a very top of file.
  • Replace all files in ./wordpress/ folder with your files.
  • Open wp-config.php file in your text editor and replace following rows:
/** The name of the database for WordPress */  
define('DB_NAME', '**********');  
/** MySQL database username */  
define('DB_USER', '**********');  
/** MySQL database password */  
define('DB_PASSWORD', '**********');  
/** MySQL hostname */  
define('DB_HOST', '**********');  

with these rows:

/** The name of the database for WordPress */  
define('DB_NAME', 'wordpress');  
/** MySQL database username */  
define('DB_USER', 'user');  
/** MySQL database password */  
define('DB_PASSWORD', 'password');  
/** MySQL hostname */  
define('DB_HOST', 'wordpress_db:3306');  
  • Start your project with docker-compose up.

Case 2: Setup existing project which was under docker previously

  • Just pull all files from git and run setup from Case 1.

Useful commands

Database Backup

docker exec wordpress_db /usr/bin/mysqldump -uuser -ppassword -B wordpress wordpress > db_dump.sql  

Database Restore

cat db_dump.sql | docker exec -i wordpress_db /usr/bin/mysql -uuser -ppassword wordpress  

Accessing containers shell

docker exec -it wordpress bash  
docker exec -it wordpress_db bash  

Accessing MySQL server inside container from host

mysql -h0.0.0.0 -P3307 -uroot -proot  

Tech

Wordpress in Docker uses a number of open source projects to work properly:

  • Docker Amazing tool which does the whole magic.
  • WordPress Open source software you can use to create a beautiful website, blog, or app.
  • phpMyAdmin Although it's not essential here for things to work, I decided to include it as this is amazing free software tool, intended to handle the administration of MySQL over the Web.
  • Official Docker Repositories WordPress, MySQL, phpMyAdmin

Licenses

Wordpress in Docker: MIT
WordPress: GPL

@2017 Eugene Golovan at S-PRO

About

The whole idea was to make starting new (or not new) WordPress project as easy as possible. Wordpress in Docker is a set of files to easily run WordPress in an isolated environment built with Docker containers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published