Issue
When using memcached with docker, how can I set the max item size?
I know the following can be done e.g. -m 64 to set the storage limit:
docker run --name my-memcache -d memcached memcached -m 64
I also know that in a Linux box the following can be done to set item max size limit:
MAXITEMSIZE=5m
Solution
The entry point script in the memcached image will pass on command line options
docker run --name my-memcache -d memcached -I 10m
If you want to make the option default to something and be configured by the MAXITEMSIZE
environment variable you could create an image FROM memcached
and copy a new entry point script in.
FROM memcached
COPY docker-entrypoint.sh /usr/local/bin/
The script needs to cater for when a user doesn't run memcached
and when they specify the -I
option manually.
#!/bin/sh
set -ue
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- memcached "$@"
fi
if [ "$1" = "memcached" ]; then
shift
MAXITEMSIZE=${MAXITEMSIZE:-1m}
set -- memcached -I "$MAXITEMSIZE" "$@"
fi
exec "$@"
Answered By - Matt Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.