PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, November 12, 2022

[FIXED] How to increase memcached item max size in docker

 November 12, 2022     docker, memcached     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing