Skip to content
Runbook

Install Memcached on Docker

High-performance, distributed in-memory cache for key-value data.

Cachecachein-memorykey-valuedistributed

Installation

Container (official image) · Docker
docker run -d --name memcached -p 11211:11211 memcached

Publishes port 11211. There is no persistence, so no volume is needed.

Verify the installation

Verify
docker exec memcached memcached -V

Default ports

11211

Command-line tools

  • memcachedThe cache server; pass flags after the image name, e.g. memcached memcached -m 256.

Uninstall

Remove the container
docker rm -f memcached

No data to clean up: Memcached keeps everything in RAM.

Good to know

  • Memcached is in-memory only; nothing to persist, so no volume is required.
  • Tune memory by appending flags: docker run -d --name memcached -p 11211:11211 memcached memcached -m 256.
  • Publishing 11211 exposes an unauthenticated cache: only do so on a trusted network, or bind to a local interface with -p 127.0.0.1:11211:11211.

Running Memcached with Docker

The official memcached image runs the server out of the box. docker run -d --name memcached -p 11211:11211 memcached publishes port 11211; verify with docker exec memcached memcached -V. Because Memcached is purely in-memory, there is nothing to persist and no volume to mount.

Tuning

Append flags after the image name (the image's entrypoint is memcached): for example docker run -d --name memcached -p 11211:11211 memcached memcached -m 256 -c 2048 sets a 256 MB cache and a higher connection limit.

Security

Publishing 11211 exposes an unauthenticated cache. On anything but an isolated network, bind the port to localhost (-p 127.0.0.1:11211:11211) or front it with a firewall, and avoid UDP exposure to prevent amplification abuse.