/memcached

Primary LanguageShellMozilla Public License 2.0MPL-2.0

Autopilot memcached

*Containerized memcached server, based on the official memcached Docker image, adding ContainerPilot to announce this container's memcached service to a Service Discovery layer, such as Consul or etcd.

DockerPulls DockerStars

Usage

Include this image in your Docker Compose project, query Consul for it's IP address and use it in your configurations, easily done via Consul-Template. The default ContainerPilot configuration talks to Consul and assumes the IP address to access consule is passed to the container in an envrionment varible, $CONSUL

Consider this example consul template from the AutoPilot Wordpress project

# included into wp-config.php

{{ if service "memcached" }}
# turn on WP caching
define('WP_CACHE', true);
define( 'WP_APC_KEY_SALT', '{{env "WORDPRESS_CACHE_KEY_SALT"}}' );
define( 'WP_CACHE_KEY_SALT', '{{env "WORDPRESS_CACHE_KEY_SALT"}}' );

global $memcached_servers;

# write the address:port pairs for each healthy memcached node
$memcached_servers = array(
    {{range service "memcached"}}
    	array(
        '{{.Address}}',
        {{.Port}}
      ),
    {{end}}
);
{{ end }}