squeakywheel/memcached
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering. It is a short-term memory for applications. Memcached allows to take memory from parts of a system where you have more than you need and make it accessible to areas where you have less than you need. Read more on the memcached website.
1.5.22-focal
, 1.5.22
, 1.5-focal
, 1.5
, 1-focal
, 1
, focal
, beta
- /!\ this is a beta releaseamd64
, arm64
, ppc64el
, s390x
$ docker run -d --name memcached -e TZ=UTC squeakywheel/memcached:edge
Parameters
Parameter | Description |
---|---|
-e TZ=UTC | Timezone. |
-e MEMCACHED_CACHE_SIZE=64MB | Determines the size of the cache. |
-e MEMCACHED_MAX_CONNECTIONS=1024 | Determines the maximum number of concurrent connections. |
-e MEMCACHED_THREADS=4 | Determines the number of threads to process requests. |
-e MEMCACHED_PASSWORD | Define the password for the root user if another username is provided. By default the authentication is disabled but if this option is passed it becomes enabled. |
-e MEMCACHED_USERNAME | Define a new user. If this option is passed a password is needed to authenticate the new user. |
-p 11211 | Memcached is exposed inside the container on port 11211 . |
Testing/Debugging
In case you need to debug what it is happening with the container you can run docker logs <name_of_the_container>
. But if you want to get access to an interactive shell run:
$ docker exec -it <name_of_the_container> /bin/bash
# Create a dedicated network
$ docker network create memcached-net
# Connect the main container to it
$ docker network connect memcached-net memcached
# Run an interactive container with the latest Ubuntu
$ docker run -it --rm --name telnet --network memcached-net ubuntu bash
# Install the telnet cli from within the container
> apt update && apt install telnet -y
# Connect to the memcached instance using telnet
> telnet memcached 11211
Trying 172.30.0.2...
Connected to memcached.
Escape character is '^]'.
From there you can run memcached
commands, as documented in their wiki.
$ telnet memcached 11211
There are cases where one might want to pass some memcached command line flags that are not configurable via environment variables. In this case you can pass the flags themselves or a shell script:
$ docker run -d squeakywheel/memcached:edge <flags_or_script_with_flags>
You can use your favorite Kubernetes distribution; if you don't have one, consider installing MicroK8s.
With microk8s running, enable the dns
and storage
add-ons:
$ microk8s enable dns storage
Use the sample deployment yaml provided here.
# memcached-deployment.yml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: memcached-deployment
spec:
replicas: 1
selector:
matchLabels:
app: memcached
template:
metadata:
labels:
app: memcached
spec:
containers:
- name: memcached
image: squeakywheel/memcached:edge
env:
- name: MEMCACHED_CACHE_SIZE
value: "128"
- name: MEMCACHED_MAX_CONNECTIONS
value: "2048"
- name: MEMCACHED_THREADS
value: "8"
- name: MEMCACHED_USERNAME
value: "john"
- name: MEMCACHED_PASSWORD
value: "pAs$wd"
ports:
- containerPort: 11211
name: memcached
protocol: TCP
$ microk8s kubectl apply -f memcached-deployment.yml
Memcached will be listening on port 31211
in your host.
If you find a bug in our image or want to request a specific feature file a bug here:
https://bugs.launchpad.net/ubuntu-docker-images/+filebug
In the title of the bug add memcached: <reason>
.
Make sure to include:
<tag>
with the one you used to run the image:$ docker images --no-trunc --quiet squeakywheel/memcached:<tag>
docker pull squeakywheel/memcached