What are Appstack Images?

The DockerDemos Appstack projects are a collection of Docker images that can run containers in various linked configurations to build a variety of application stacks.

For example, a basic WordPress service consists of -

  1. Storage
  2. A database server
  3. A web server
  4. A PHP processor
  5. The WordPress code

With Appstack images, you can build an entire WordPress service from zero to fully installed and ready to accept content, all inside Docker containers. With a handy script, it can be done in seconds!

Depending on the images used, you could have a full WordPress instance, or a Drupal site, or a basic LAMP stack, or in the near future, Ruby on Rails, Django, etc.. It just depends only on the chosen images and how they are linked.

Appstack Image Reference

  • appstack-data: A data-only container image- the heart that ties all the Appstack containers together
  • appstack-setup-mysql: A MariaDB pre-configuration container image that runs once to initialize a MariaDB server.
  • appstack-mysql: A MariaDB container image for running your database server.
  • appstack-phpfpm: A PHP FastCGI Process Manager container image
  • appstack-apache: An Apache web server container image; designed to offload PHP processing to the appstack-phpfpm containers.
  • appstack-wpcli: A WP-CLI container image, for automating installation, upgrades and management of WordPress sites run in an Appstack container stack.
  • appstack-drush: A Drush container image, for automating installation, upgrades and management of Drupal sites run in an Appstack container stack.
  • appstack-backup: An container image for automating MariaDB database backups.

Deprecated Images

  • appstack-setup-drupal: A Drupal container image for automating the install of a Drupal website inside an Appstack container stack.
  • appstack-setup-wp: A WordPress container image for automating WordPress websites installs with other Appstack containers.

Appstack-Data

The Appstack-data image is the heart of any group of linked Appstack images. It allows you to share storage volumes among the linked containers easily, and to mount volumes from your host into the Appstack stack (eg. /var/lib/mysql, or /var/www/html - for persistence).

Github Repo: https://github.com/DockerDemos/appstack-data

Issue Tracker: https://github.com/DockerDemos/appstack-data/issues

The Appstack-data image currently allows linked containers to share the following volumes:

  • /var/www/html
  • /var/lib/mysql
  • /var/log
  • /var/backup
  • /conf
  • /conf/.creds

You can mount directories from your host server into these volumes by passing the -v <host directory>:<data container volume> argument when starting the data container. In addition, volumes can be shared by passing the --volumes-from <data container name> argument to any linked containers when they are started.

Example of mounting host volumes inside the data container:

docker run --name data -v /srv/html:/var/www/html -v /srv/mysql:/var/lib/mysql -v /srv/log:/var/log -v /srv/backup:/var/backup -v /srv/conf:/conf -it appstack-data

Appstack-Setup-MySQL

The Appstack-Setup-MySQL image is a single-use configuration image used to initialize a MariaDB database before an Appstack-MySQL container is run. This image is designed to run only once per stack, and should be run after the Data container has started, and before the MySQL container is started.

Github Repo: https://github.com/DockerDemos/appstack-setup-mysql

Issue Tracker: https://github.com/DockerDemos/appstack-setup-mysql/issues

The Appstack-Setup-MySQL image requires only the --volumes-from <data container name> argument to be passed when run. It does not need anything else to function.

When run, it will run the mysql_install_db command to initialize the MariaDB database. It will set the root password, create a backup user and password, and create a randomly-named database. It will then store this information in /conf/.creds/dbdata.yaml in the data container. The dbdata.yaml file is used by other appstack containers to setup applications requiring a database.

Example:

docker run --volumes-from data -it appstack-setup-mysql

...where "data" is the name chosen for the data container.

Appstack-MySQL

The Appstack-MySQL images is a simple MariaDB database server inside a Docker container. It requires only that the Appstack-Setup-MySQL container is run before starting for the first time. After that, the Appstack-MySQL image can start the database container again in the future without the extra initializations step. Github Repo: https://github.com/DockerDemos/appstack-mysql

Issue Tracker: https://github.com/DockerDemos/appstack-mysql/issues

Example:

docker run --volumes-from data --name db -d appstack-mysql

...where "data" is the name chosen for the data container, and "db" is the name to be assigned to the database container.

Appstack-PHPFPM

Appstack-PHPFPM

The Appstack-PHPFPM image runs a PHP-FPM server and is used for any application stacks that require PHP processing (Basic LAMP, WordPress, etc).

Github Repo: https://github.com/DockerDemos/appstack-phpfpm

Issue Tracker: https://github.com/DockerDemos/appstack-phpfpm/issues

The Appstack-PHPFPM image needs a few things to be useful:

  • The code you wish to run mounted in /var/www/html (usually with --volumes-from a data container)
  • Linked to the database container with the alias db
  • Optionally, an environment variable for SMTPSERVER, to enable email support
  • Optionally, an environment variable for DOMAIN.

Specifying an SMTP server in the SMTPSERVER environment variable will enable outgoing email support for PHP (using SSMTP for sendmail). If you do not supply a DOMAIN environment variable, the container will try to parse the third-level domain from SMTPSERVER.

Example:

docker run --volumes-from data --name fpm --link db:db  -d appstack-phpfpm

...where "data" is the name chosen for the data container,"db" is the name assigned to the database container, and "fpm" is the name to be assigned to the database container.

Appstack-Apache

The Appstack-Apache image is a front end for PHP-FPM. Mod_FASTCGI is built into the image, and it's pre-configured to connect to a PHP-FPM container. Currently, this is the only working Apache image, but other images are in development now for Python WSGI, Ruby on Rails and, as an alternative to Apache, Nginx.

Github Repo: https://github.com/DockerDemos/appstack-apache

Issue Tracker: https://github.com/DockerDemos/appstack-apache/issues

The Appstack-Apache images is currently the most complicated to run. It requires several things:

  • A /conf directory that includes an SSL key and certificates (REQUIRED, but may be self-signed).
  • The SSL key and cert named localhost.key and localhost.crt, respectively
  • An optional ca-cert.crt that includes your certificate authority's intermediate cert bundle.
  • The files to be served in /var/www/html
  • Port 80 and port 443 mapped to ports on your host
  • An SITENAME environment variable with the domain for your website.

Both /conf and /var/www/html are most easily provided to the Appstack-Apache container by mapping --volumes-from a data container.

Example:

docker run --volumes-from data --link fpm:fpm --name web -p 80:80 -p 443:443 -e 'SITENAME=your.site.name' -d appstack-apache

Appstack-WPCLI

The Appstack-WPCLI image is designed to accept all the regular WP-CLI commands, as well as run a few helper scripts to assist in automating WordPress managemtn with other Appstack containers.

Github Repo: https://github.com/DockerDemos/appstack-wpcli

Issue Tracker: https://github.com/DockerDemos/appstack-wpcli/issues

Examples

Download WordPress from WordPress.org:

docker run --volumes-from data -w /var/www/html -it appstack-wpcli /scripts/core-download.sh

Setup the wp-config.php file inside an Appstack stack (assumes a dbdata.yaml file exists):

docker run --volumes-from data -w /var/www/html -it appstack-wpcli /scripts/core-config.sh

This reads the DB config information from dbdata.yaml, setup by the appstack-setup-mysql container.

Finalize the WP install:

docker run --link db:db --volumes-from data -w /var/www/html -e SITENAME="https://${SITENAME}" -e TITLE=hastur -e ADMIN=joebob -e ADMINPASS=foobarbaz -e ADMINEMAIL=joe.bob@example.org -it appstack-wpcli /scripts/core-install.sh

Example Plugin install:

docker run --link db:db --volumes-from data -w /var/www/html -it appstack-wpcli wp plugin install shibboleth --activate

This installs and activates the "Shibboleth" plugin from WordPress.org. However, it doesn't configure the plugin, just turns it on. That leads to the next useful command...

Arbitrary SQL Queries:

docker run --link db:db --volumes-from data -w /var/www/html -it appstack-wpcli wp db query "select * from wp_options where option_id=1 \G"

This lets you run a query (including UPDATE) on the WP database using the info in the wp-config.php file. This way you could potentially pre-configure any specific plugin settings that aren't setup by default - such as the Shibboleth stuff, for instance.

Appstack-Drush

Appstack-Drush contains a Drush install and accepts all standard Drush Commands. The image can be used to install and manage a Drupal website inside linked containers, either the standard Appstack stack, or another Docker container (or even a real host!) In addition to accepting the usual Drush commands when run, the Appstack-Drush image also has a couple of scripts to assist in easily setting up a Drupal install for the first time.

Github Repo: https://github.com/DockerDemos/appstack-drush

Issue Tracker: https://github.com/DockerDemos/appstack-drush/issues

Examples

Note - In these examples:

  1. "db" refers to a Docker container with a running MySQL database in it
  2. "data" refers to a container with the desired Document Root

Download Drupal core from Drupal.org:

docker run --volumes-from data -w /var/www/html -it appstack-drush /scripts/core-download.sh

Run a Drupal install inside of an Appstack stack (assumes a dbdata.yaml file exists):

docker run --volumes-from data --link db:db \
       -e TITLE=<your_site_title> -e ADMINEMAIL=<admin_emai_address> \
   -e ADMIN=<admin_username> -e ADMINPASS=<initial_admin_password> \
   -it appstack-drush /scripts/core-install.sh

Disable a Drupal user account:

docker run --volumes-from data --link db:db -it appstack-drush drush ublk --uid <Drush UID of user>

Arbitrary SQL Queries:

docker run --volumes-from data --link db:db -it appstack-drush drush sqlq <some SQL query>

Appstack-Backup

https://github.com/DockerDemos/appstack-backup

Documentation coming soon.

Appstack-Setup-Drupal

Appstack-Setup-Drupal is deprecated in favor of appstack-drush, and will no longer be maintained.

Github Repo: https://github.com/DockerDemos/appstack-setup-drupal

Appstack-Setup-WP

Appstack-Setup-WP is deprecated in favor of appstack-wpcli, and will no longer be maintained.

Github Repo: https://github.com/DockerDemos/appstack-setup-wp

DockerDemos/Appstack Dockerfiles and related container files are:

Copyright (C) 2014-2015 Chris Collins

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.