This is a custom Docker image for Memcached (based on this docker compose setup in the Zulip docs), preconfigured to support SASL authentication using plain-text authentication. It automatically sets up the SASL configuration and password database at runtime.
I created it because I was trying to self-host Zulip via Dokku, and couldn't find a decent way to configure Memcached as in the above setup, using the Official memcached plugin for dokku.
- Memcached version
1.6.29-alpine
- SASL authentication enabled
- Custom environment variables for SASL configuration
- Automatically generates the SASL configuration file and user password database
-
Clone the repository to your local machine:
git clone https://github.com/engineervix/docker-memcached-sasl.git cd memcached-sasl
-
Build the Docker image:
docker build -t your-dockerhub-username/memcached-sasl .
-
Push the image to Docker Hub (or another container registry):
docker push your-dockerhub-username/memcached-sasl
The following environment variables can be configured when running the container:
SASL_CONF_PATH
: Path to the SASL configuration file (default:/home/memcache/memcached.conf
).MEMCACHED_SASL_PWDB
: Path to the SASL password database (default:/home/memcache/memcached-sasl-db
).MEMCACHED_PASSWORD
: Password used for thezulip
user (default:"REPLACE_WITH_SECURE_MEMCACHED_PASSWORD"
).
-
The entrypoint script creates the SASL configuration file at the location specified by
SASL_CONF_PATH
. This file enables the plain-text mechanism for SASL authentication. -
The script generates a password database file (
MEMCACHED_SASL_PWDB
), containing credentials for the userzulip
. The username is set aszulip@localhost
with the password defined byMEMCACHED_PASSWORD
. -
The
memcached -S
command starts Memcached with SASL authentication enabled, enforcing user authentication for all clients.
You can run the image directly using Docker:
docker run -d \
-e MEMCACHED_PASSWORD=your_secure_password \
your-dockerhub-username/memcached-sasl
Or, use this image in a Dokku setup:
sudo dokku memcached:create memcached-zulip \
--image "your-dockerhub-username/memcached-sasl" \
--image-version "latest" \
--custom-env "MEMCACHED_PASSWORD=your_secure_password"
- If you want to customize the SASL mechanism or add more users, you can modify the
Dockerfile
or adjust the entrypoint script. - For a more secure setup, ensure that the
MEMCACHED_PASSWORD
environment variable is set to a strong, random value.