https://github.com/engineervix/docker-memcached-sasl
a custom Docker image for Memcached, created for use with Zulip
https://github.com/engineervix/docker-memcached-sasl
Last synced: about 1 month ago
JSON representation
a custom Docker image for Memcached, created for use with Zulip
- Host: GitHub
- URL: https://github.com/engineervix/docker-memcached-sasl
- Owner: engineervix
- License: mit
- Created: 2024-09-05T01:33:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-15T07:56:06.000Z (7 months ago)
- Last Synced: 2025-08-20T00:22:50.506Z (7 months ago)
- Language: Dockerfile
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Memcached with SASL Authentication
[](https://github.com/engineervix/docker-memcached-sasl/actions/workflows/build-docker-image.yml)
[](https://github.com/engineervix/docker-memcached-sasl/actions/workflows/publish-docker-image.yml)
This is a custom Docker image for Memcached (based on [this docker compose setup in the Zulip docs](https://github.com/zulip/docker-zulip/blob/6a75497a17e4ed727fb011f39f84cd64ac9ea36f/docker-compose.yml#L18C1-L25C26)), 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](https://dokku.com/), and couldn't find a decent way to configure Memcached as in the above setup, using the [Official memcached plugin for dokku](https://github.com/dokku/dokku-memcached).
## Features
- 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
## Usage
### Build the Image
1. Clone the repository to your local machine:
```bash
git clone https://github.com/engineervix/docker-memcached-sasl.git
cd memcached-sasl
```
2. Build the Docker image:
```bash
docker build -t your-dockerhub-username/memcached-sasl .
```
3. Push the image to Docker Hub (or another container registry):
```bash
docker push your-dockerhub-username/memcached-sasl
```
### Environment Variables
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 the `zulip` user (default: `"REPLACE_WITH_SECURE_MEMCACHED_PASSWORD"`).
### How It Works
1. 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.
2. The script generates a password database file (`MEMCACHED_SASL_PWDB`), containing credentials for the user `zulip`. The username is set as `zulip@localhost` with the password defined by `MEMCACHED_PASSWORD`.
3. The `memcached -S` command starts Memcached with SASL authentication enabled, enforcing user authentication for all clients.
### Running the Image
You can run the image directly using Docker:
```bash
docker run -d \
-e MEMCACHED_PASSWORD=your_secure_password \
your-dockerhub-username/memcached-sasl
```
Or, use this image in a Dokku setup:
```bash
sudo dokku memcached:create memcached-zulip \
--image "your-dockerhub-username/memcached-sasl" \
--image-version "latest" \
--custom-env "MEMCACHED_PASSWORD=your_secure_password"
```
### Customization
- 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.
---