From: W. Trevor King Date: Sat, 28 Dec 2013 21:24:24 +0000 (-0800) Subject: memcached: Add a Memcached image X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e1a3dca924676ba2b9c90ad11eb495544dd48612;p=dockerfile.git memcached: Add a Memcached image The 10MB of overhead memory were estimated from this output in a running memcached container: # ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 20300 2124 ? S 20:57 0:00 /bin/bash memcach+ 184 0.0 0.0 323124 1112 ? Ssl 20:58 0:00 /usr/bin/memcached -d -p 11211 -U 11211 -m 128 -c 1024 -u root 224 0.0 0.0 25064 440 ? S 20:58 0:00 supervising syslog-ng root 225 0.3 0.0 124708 3620 ? Ssl 20:58 0:00 /usr/sbin/syslog-ng --persist-file /var/lib/syslog-ng/sysl root 263 0.0 0.0 18632 804 ? Ss 20:58 0:00 /usr/sbin/cron root 300 0.0 0.0 15440 1148 ? R+ 20:58 0:00 ps aux Less Bash and ps, that's 1112 + 3620 + 804 = 5.5MB of resident memory, so 10MB seemed like a safe buffer. --- diff --git a/README.md b/README.md index 77f6516..f11c5cb 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ The dependency graph is: `-- gentoo-en-us (adds locale) `-- gentoo-syslog (adds syslog-ng and associates) |-- buildbot (adds a Buildbot master and slave) + |-- memcached (adds Memcached) |-- nginx (adds Nginx) | `-- kibana (adds Kibana) |-- postgresql (adds PostgreSQL) diff --git a/build.sh b/build.sh index 55dcbb3..d4ad779 100755 --- a/build.sh +++ b/build.sh @@ -44,6 +44,7 @@ REPOS="${REPOS:- gentoo-java buildbot elasticsearch + memcached nginx kibana postgresql diff --git a/memcached/Dockerfile.template b/memcached/Dockerfile.template new file mode 100644 index 0000000..4522fcb --- /dev/null +++ b/memcached/Dockerfile.template @@ -0,0 +1,36 @@ +# Copyright (C) 2013 W. Trevor King +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +FROM NAMESPACE/gentoo-syslog:TAG +MAINTAINER A. U. Thor +#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"] +RUN emerge -v net-misc/memcached +RUN eselect news read new +RUN rc-update add memcached default + +# Container networking happens automatically +RUN sed -i 's/need net$/use net/' /etc/init.d/* + +CMD sed -i "s/^MEMUSAGE=.*/MEMUSAGE=\"${MEMUSAGE}\"/" /etc/conf.d/memcached && rc default && tail -F /var/log/messages +EXPOSE 11211 diff --git a/memcached/README.md b/memcached/README.md new file mode 100644 index 0000000..7b27cec --- /dev/null +++ b/memcached/README.md @@ -0,0 +1,22 @@ +Run this [Memcached][] image with: + + $ docker run -d -name memcached-0 -m 128m -e MEMUSAGE=118 wking/memcached + +The 10MB difference between container memory and the +Memcached-specific `MEMUSAGE` limit gives some overhead for the +`memcached` process itself and auxilliary processes to ensure that +`MEMUSAGE` stops us before we hit “out of memory” errors. + +Then [link][linking] to it from your client container: + + $ docker run -link memcached-0:memcached your-client + +Inside your client, use the `MEMCACHED_PORT` environment variable +(which should be something like `tcp://172.17.0.8:11211`) to configure +your client's Memcached connection. Linking like this *does not* +expose the port on your host interface (that's what `-p` is for). You +can spin up as many Memcached containers as you like (`memcached-1`, +`memcached-2`, …), and link to any of them from any client container. + +[Memcached]: http://memcached.org/ +[linking]: http://docs.docker.io/en/latest/use/port_redirection/#linking-a-container