From 5097d0e7d481eedc4525421e23d8037c2308bc55 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Wed, 12 Apr 2017 10:15:36 +0200 Subject: [PATCH 1/5] Add missing files directory Signed-off-by: Petr "Stone" Hracek --- files/memcached.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 files/memcached.sh diff --git a/files/memcached.sh b/files/memcached.sh new file mode 100755 index 0000000..abf2c9e --- /dev/null +++ b/files/memcached.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [[ ! -z "${DEBUG_MODE}" ]]; then + rpm -q syslog-ng + if [[ $? -ne 0 ]]; then + dnf -y --setopt=tsflags=nodocs install syslog-ng && \ + dnf -y clean all + syslog-ng + fi + +fi + +# Run memcached binary +/usr/bin/memcached \ No newline at end of file From 79b840a5ebddaf0d65349d7a8668833759c7401a Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: Mon, 21 Aug 2017 17:00:44 +0200 Subject: [PATCH 2/5] sync with upstream Signed-off-by: Tomas Tomecek --- Dockerfile | 9 ++++--- files/memcached.sh | 8 +++++++ root/help.1 | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 root/help.1 diff --git a/Dockerfile b/Dockerfile index 5215f6a..a57159b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.fedoraproject.org/fedora:26 +FROM registry.fedoraproject.org/f26-modular/boltron # memcached image for OpenShift. # @@ -15,7 +15,7 @@ LABEL summary="High Performance, Distributed Memory Object Cache" \ release="1.$DISTTAG" \ architecture="$ARCH" \ com.redhat.component=$NAME \ - usage="docker run -p 11211:11211 f26/memcached" \ + usage="docker run -p 11211:11211 registry.fedoraproject.org/f26-modular/memcached" \ help="Runs memcached, which listens on port 11211. No dependencies. See Help File below for more details." \ description="memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load." \ io.k8s.description="memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load." \ @@ -23,12 +23,11 @@ LABEL summary="High Performance, Distributed Memory Object Cache" \ io.openshift.expose-services="11211:memcached" \ io.openshift.tags="memcached" -RUN dnf install -y --setopt=tsflags=nodocs memcached && \ +RUN dnf -y --nodocs install memcached && \ dnf -y clean all - ADD files /files -ADD help.md README.md / +ADD root/help.1 /help.1 EXPOSE 11211 diff --git a/files/memcached.sh b/files/memcached.sh index abf2c9e..d7bace4 100755 --- a/files/memcached.sh +++ b/files/memcached.sh @@ -1,5 +1,7 @@ #!/bin/bash +MEMCACHED_CONF="/etc/sysconfig/memcached" + if [[ ! -z "${DEBUG_MODE}" ]]; then rpm -q syslog-ng if [[ $? -ne 0 ]]; then @@ -10,5 +12,11 @@ if [[ ! -z "${DEBUG_MODE}" ]]; then fi +if [[ ! -z "${THREADS_NUM}" ]]; then + grep "OPTIONS=" $MEMCACHED_CONF + if [[ $? -eq 0 ]]; then + echo "OPTIONS="-l 127.0.0.1,::1 -t ${THREADS_NUM}"" >> $MEMCACHED_CONF + fi +fi # Run memcached binary /usr/bin/memcached \ No newline at end of file diff --git a/root/help.1 b/root/help.1 new file mode 100644 index 0000000..4056147 --- /dev/null +++ b/root/help.1 @@ -0,0 +1,60 @@ +.TH "MEMCACHED" "1" " Container Image Pages" "Petr Hracek" "February 6, 2017" +.nh +.ad l + + +.SH NAME +.PP +memcached \- High Performance, Distributed Memory Object Cache. + + +.SH DESCRIPTION +.PP +Memcached is a high\-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. + +.PP +The container itself consists of: + \- fedora/24 base image + \- memcached RPM package + +.PP +Files added to the container during docker build include: /files/memcached.sh + + +.SH USAGE +.PP +To get the memcached container image on your local system, run the following: + +.PP +.RS + +.nf +docker pull hub.docker.io/phracek/memcached + +.fi +.RE + + +.SH ENVIRONMENT VARIABLES +.PP +The memcached container includes the following environment variables: + +.PP +CACHE\_SIZE=128 + The variable sets size of cached used by memcached. + + +.SH SECURITY IMPLICATIONS +.PP +Lists of security\-related attributes that are opened to the host. + +.PP +\-p 11211:11211 + Opens container port 11211 and maps it to the same port on the host. + + +.SH SEE ALSO +.PP +Memcached page + +\[la]https://memcached.org/\[ra] From 71ccb35e585f764aa4630842aaacc81c9d147352 Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: Mon, 21 Aug 2017 21:44:20 +0200 Subject: [PATCH 3/5] rebuild - bump release Signed-off-by: Tomas Tomecek --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a57159b..cc874b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ LABEL MAINTAINER "Petr Hracek" LABEL summary="High Performance, Distributed Memory Object Cache" \ name="$FGC/$NAME" \ version="0" \ - release="1.$DISTTAG" \ + release="2.$DISTTAG" \ architecture="$ARCH" \ com.redhat.component=$NAME \ usage="docker run -p 11211:11211 registry.fedoraproject.org/f26-modular/memcached" \ From 5a4b8a61530d63178e00500faec196b65ac44c38 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Wed, 6 Sep 2017 12:15:32 +0200 Subject: [PATCH 4/5] Update container image according to Fedora-Dockerfiles --- Dockerfile | 6 +- README.md | 184 +++++++++++++++++++-------------------------- files/memcached.sh | 29 +++---- help.md | 17 ++++- 4 files changed, 110 insertions(+), 126 deletions(-) diff --git a/Dockerfile b/Dockerfile index cc874b7..c7fa51f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.fedoraproject.org/f26-modular/boltron +FROM registry.fedoraproject.org/fedora:rawhide # memcached image for OpenShift. # @@ -12,10 +12,10 @@ LABEL MAINTAINER "Petr Hracek" LABEL summary="High Performance, Distributed Memory Object Cache" \ name="$FGC/$NAME" \ version="0" \ - release="2.$DISTTAG" \ + release="3.$DISTTAG" \ architecture="$ARCH" \ com.redhat.component=$NAME \ - usage="docker run -p 11211:11211 registry.fedoraproject.org/f26-modular/memcached" \ + usage="docker run -p 11211:11211 registry.fedoraproject.org/rawhide/memcached" \ help="Runs memcached, which listens on port 11211. No dependencies. See Help File below for more details." \ description="memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load." \ io.k8s.description="memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load." \ diff --git a/README.md b/README.md index 83659cc..2182789 100644 --- a/README.md +++ b/README.md @@ -2,111 +2,85 @@ Memcached is High Performance, Distributed Memory Object Cache -## Summary +## How to use the container + +Pull the image from Docker Hub: + +```bash +$ sudo docker pull registry.fedoraproject.org/memcached:rawhide +``` + +Run the container + +```bash +docker run -it -p 11211:11211 --name memcached modularitycontainers/memcached +``` + +If you would like to debug memcached, use container option =e MEMCACHED_DEBUG_MODE: +```bash +docker run -it -p 11211:11211 +[-e MEMCACHED_DEBUG_MODE] +--name memcached modularitycontainers/memcached +``` + +If you would like to change memcached options, like cache_size, connections or threads, use environment variable -e MEMCACHED_CACHE_SIZE, -e MEMCACHED_CONNECTIONS, -e MEMCACHED_THREADS respectively: +```bash +docker run -it -p 11211:11211 +[-e MEMCACHED_CACHE_SIZE=] +[-e MEMCACHED_CONNECTIONS=] +[-e MEMCACHED_THREADS=] +--name memcached modularitycontainers/memcached +``` + +## A demo + +Here is a simple demo how to run memcached + +* Copy systemd service which will take care of memcached container: + ```bash + $ sudo cp -av memcached-container.service /usr/lib/systemd/system/ + $ sudo systemctl daemon-reload + ``` + +* We can start memcached now: + ```bash + $ sudo systemctl start memcached-container + ``` + +* You should be able to test memcached by commands (taken from http://www.journaldev.com/16/memcached-telnet-commands-with-example): + ```bash + set Test 0 100 10 + JournalDev + STORED + get Test + VALUE Test 0 10 + JournalDev + END + replace Test 0 100 4 + Temp + STORED + get Test + VALUE Test 0 4 + Temp + END + stats items + STAT items:1:number 1 + STAT items:1:age 19 + STAT items:1:evicted 0 + STAT items:1:evicted_time 0 + STAT items:1:outofmemory 0 + STAT items:1:tailrepairs 0 + END + flush_all + OK + get Test + END + version + VERSION 1.4.25 + quit + ``` + +## Repository structure - Dockerfile - build container image with memcached. - openshift-template.yml - Template for OpenShift to memcached. - - -## How to use the container over standard 11211 port - -Command for running memcached docker container: - -```bash -docker run -it -e CACHE_SIZE=128 \ - -p 11211:11211 -``` - -If you would like to increase a CACHE_SIZE use environment variable -e CACHE_SIZE: -```bash -docker run -it -e CACHE_SIZE=128 \ - -p 11211:11211 -``` - -## How to run memcached as standalone container - -Copy memcached-container.service to ```/usr/lib/systemd/user/``` directory -```bash -sudo cp memcached-container.service /usr/lib/systemd/user/ -systemctl --user daemon-reload -``` - -Command for running memcached as standalone container: -```bash -systemctl start --user memcached-container -``` - -## How to stop memcached as standalone container -Command for stopping memcached as standalone container: -```bash -systemctl stop --user memcached-container -``` -## How to test the memcached - -Commands for testing memcached docker container: - -To store data in memcached server with telnet: -```bash -set KEY META_DATA EXPIRY_TIME LENGTH_IN_BYTES -``` - -To get data -```bash -get KEY -``` - -To overwrite existing key -```bash -replace KEY META_DATA EXPIRE_TIME LENGTH_IN_BYTES -``` - -To delete key -```bash -delete KEY -``` - -To get the server statistics -```bash -stats -stats items -stats slabs - -``` - -To clear the metadata statistics -```bash -flush all -``` - -Memcached Server Telnet Example (taken from http://www.journaldev.com/16/memcached-telnet-commands-with-example) -```bash -set Test 0 100 10 -JournalDev -STORED -get Test -VALUE Test 0 10 -JournalDev -END -replace Test 0 100 4 -Temp -STORED -get Test -VALUE Test 0 4 -Temp -END -stats items -STAT items:1:number 1 -STAT items:1:age 19 -STAT items:1:evicted 0 -STAT items:1:evicted_time 0 -STAT items:1:outofmemory 0 -STAT items:1:tailrepairs 0 -END -flush_all -OK -get Test -END -version -VERSION 1.4.25 -quit -``` diff --git a/files/memcached.sh b/files/memcached.sh index d7bace4..96bbd16 100755 --- a/files/memcached.sh +++ b/files/memcached.sh @@ -1,22 +1,23 @@ #!/bin/bash -MEMCACHED_CONF="/etc/sysconfig/memcached" +MEMCACHED_ARGS= -if [[ ! -z "${DEBUG_MODE}" ]]; then - rpm -q syslog-ng - if [[ $? -ne 0 ]]; then - dnf -y --setopt=tsflags=nodocs install syslog-ng && \ - dnf -y clean all - syslog-ng - fi +if [[ ! -z "${MEMCACHED_DEBUG_MODE}" ]]; then + MEMCACHED_ARGS+=" -vv" fi -if [[ ! -z "${THREADS_NUM}" ]]; then - grep "OPTIONS=" $MEMCACHED_CONF - if [[ $? -eq 0 ]]; then - echo "OPTIONS="-l 127.0.0.1,::1 -t ${THREADS_NUM}"" >> $MEMCACHED_CONF - fi +if [[ ! -z "${MEMCACHED_CACHE_SIZE}" ]]; then + MEMCACHED_ARGS+=" -m $MEMCACHED_CACHE_SIZE" fi + +if [[ ! -z "${MEMCACHED_CONNECTIONS}" ]]; then + MEMCACHED_ARGS+=" -c $MEMCACHED_CONNECTIONS" +fi + +if [[ ! -z "${MEMCACHED_THREADS}" ]]; then + MEMCACHED_ARGS+=" -t $MEMCACHED_THREADS" +fi + # Run memcached binary -/usr/bin/memcached \ No newline at end of file +/usr/bin/memcached -u daemon $MEMCACHED_ARGS diff --git a/help.md b/help.md index a40d514..8569dde 100644 --- a/help.md +++ b/help.md @@ -9,7 +9,7 @@ memcached - High Performance, Distributed Memory Object Cache. Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. The container itself consists of: - - fedora/24 base image + - fedora/rawhide base image - memcached RPM package Files added to the container during docker build include: /files/memcached.sh @@ -17,14 +17,23 @@ Files added to the container during docker build include: /files/memcached.sh # USAGE To get the memcached container image on your local system, run the following: - docker pull hub.docker.io/phracek/memcached + docker pull registry.fedoraproject.org/memcached:rawhide # ENVIRONMENT VARIABLES The memcached container includes the following environment variables: -CACHE_SIZE=128 - The variable sets size of cached used by memcached. +For turn on verbose mode, use environment variable +-e MEMCACHED_DEBUG_MODE + +For setting cache size, use environment variable +-e MEMCACHED_CACHE_SIZE + +For setting maximum connections, use environment variable +-e MEMCACHED_CONNECTIONS + +For setting maximum threads, use environment variable +-e MEMCACHED_THREADS # SECURITY IMPLICATIONS Lists of security-related attributes that are opened to the host. From b72afda5118796f6465fbf3dafd4bfbf5672b568 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Wed, 6 Sep 2017 12:35:29 +0200 Subject: [PATCH 5/5] Update container image according to Fedora-Dockerfiles --- Dockerfile | 4 +- README.md | 184 +++++++++++++++++++-------------------------- files/memcached.sh | 23 ++++++ help.md | 17 ++++- 4 files changed, 117 insertions(+), 111 deletions(-) create mode 100755 files/memcached.sh diff --git a/Dockerfile b/Dockerfile index 5215f6a..e206fda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,10 +12,10 @@ LABEL MAINTAINER "Petr Hracek" LABEL summary="High Performance, Distributed Memory Object Cache" \ name="$FGC/$NAME" \ version="0" \ - release="1.$DISTTAG" \ + release="2.$DISTTAG" \ architecture="$ARCH" \ com.redhat.component=$NAME \ - usage="docker run -p 11211:11211 f26/memcached" \ + usage="docker run -p 11211:11211 registry.fedoraproject.org/f26/memcached" \ help="Runs memcached, which listens on port 11211. No dependencies. See Help File below for more details." \ description="memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load." \ io.k8s.description="memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load." \ diff --git a/README.md b/README.md index 83659cc..c112c86 100644 --- a/README.md +++ b/README.md @@ -2,111 +2,85 @@ Memcached is High Performance, Distributed Memory Object Cache -## Summary +## How to use the container + +Pull the image from Docker Hub: + +```bash +$ sudo docker pull registry.fedoraproject.org/f26/memcached +``` + +Run the container + +```bash +docker run -it -p 11211:11211 --name memcached registry.fedoraproject.org/f26/memcached +``` + +If you would like to debug memcached, use container option =e MEMCACHED_DEBUG_MODE: +```bash +docker run -it -p 11211:11211 +[-e MEMCACHED_DEBUG_MODE] +--name memcached registry.fedoraproject.org/f26/memcached +``` + +If you would like to change memcached options, like cache_size, connections or threads, use environment variable -e MEMCACHED_CACHE_SIZE, -e MEMCACHED_CONNECTIONS, -e MEMCACHED_THREADS respectively: +```bash +docker run -it -p 11211:11211 +[-e MEMCACHED_CACHE_SIZE=] +[-e MEMCACHED_CONNECTIONS=] +[-e MEMCACHED_THREADS=] +--name memcached registry.fedoraproject.org/f26/memcached +``` + +## A demo + +Here is a simple demo how to run memcached + +* Copy systemd service which will take care of memcached container: + ```bash + $ sudo cp -av memcached-container.service /usr/lib/systemd/system/ + $ sudo systemctl daemon-reload + ``` + +* We can start memcached now: + ```bash + $ sudo systemctl start memcached-container + ``` + +* You should be able to test memcached by commands (taken from http://www.journaldev.com/16/memcached-telnet-commands-with-example): + ```bash + set Test 0 100 10 + JournalDev + STORED + get Test + VALUE Test 0 10 + JournalDev + END + replace Test 0 100 4 + Temp + STORED + get Test + VALUE Test 0 4 + Temp + END + stats items + STAT items:1:number 1 + STAT items:1:age 19 + STAT items:1:evicted 0 + STAT items:1:evicted_time 0 + STAT items:1:outofmemory 0 + STAT items:1:tailrepairs 0 + END + flush_all + OK + get Test + END + version + VERSION 1.4.25 + quit + ``` + +## Repository structure - Dockerfile - build container image with memcached. - openshift-template.yml - Template for OpenShift to memcached. - - -## How to use the container over standard 11211 port - -Command for running memcached docker container: - -```bash -docker run -it -e CACHE_SIZE=128 \ - -p 11211:11211 -``` - -If you would like to increase a CACHE_SIZE use environment variable -e CACHE_SIZE: -```bash -docker run -it -e CACHE_SIZE=128 \ - -p 11211:11211 -``` - -## How to run memcached as standalone container - -Copy memcached-container.service to ```/usr/lib/systemd/user/``` directory -```bash -sudo cp memcached-container.service /usr/lib/systemd/user/ -systemctl --user daemon-reload -``` - -Command for running memcached as standalone container: -```bash -systemctl start --user memcached-container -``` - -## How to stop memcached as standalone container -Command for stopping memcached as standalone container: -```bash -systemctl stop --user memcached-container -``` -## How to test the memcached - -Commands for testing memcached docker container: - -To store data in memcached server with telnet: -```bash -set KEY META_DATA EXPIRY_TIME LENGTH_IN_BYTES -``` - -To get data -```bash -get KEY -``` - -To overwrite existing key -```bash -replace KEY META_DATA EXPIRE_TIME LENGTH_IN_BYTES -``` - -To delete key -```bash -delete KEY -``` - -To get the server statistics -```bash -stats -stats items -stats slabs - -``` - -To clear the metadata statistics -```bash -flush all -``` - -Memcached Server Telnet Example (taken from http://www.journaldev.com/16/memcached-telnet-commands-with-example) -```bash -set Test 0 100 10 -JournalDev -STORED -get Test -VALUE Test 0 10 -JournalDev -END -replace Test 0 100 4 -Temp -STORED -get Test -VALUE Test 0 4 -Temp -END -stats items -STAT items:1:number 1 -STAT items:1:age 19 -STAT items:1:evicted 0 -STAT items:1:evicted_time 0 -STAT items:1:outofmemory 0 -STAT items:1:tailrepairs 0 -END -flush_all -OK -get Test -END -version -VERSION 1.4.25 -quit -``` diff --git a/files/memcached.sh b/files/memcached.sh new file mode 100755 index 0000000..96bbd16 --- /dev/null +++ b/files/memcached.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +MEMCACHED_ARGS= + + +if [[ ! -z "${MEMCACHED_DEBUG_MODE}" ]]; then + MEMCACHED_ARGS+=" -vv" +fi + +if [[ ! -z "${MEMCACHED_CACHE_SIZE}" ]]; then + MEMCACHED_ARGS+=" -m $MEMCACHED_CACHE_SIZE" +fi + +if [[ ! -z "${MEMCACHED_CONNECTIONS}" ]]; then + MEMCACHED_ARGS+=" -c $MEMCACHED_CONNECTIONS" +fi + +if [[ ! -z "${MEMCACHED_THREADS}" ]]; then + MEMCACHED_ARGS+=" -t $MEMCACHED_THREADS" +fi + +# Run memcached binary +/usr/bin/memcached -u daemon $MEMCACHED_ARGS diff --git a/help.md b/help.md index a40d514..a837244 100644 --- a/help.md +++ b/help.md @@ -9,7 +9,7 @@ memcached - High Performance, Distributed Memory Object Cache. Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. The container itself consists of: - - fedora/24 base image + - fedora/f26 base image - memcached RPM package Files added to the container during docker build include: /files/memcached.sh @@ -17,14 +17,23 @@ Files added to the container during docker build include: /files/memcached.sh # USAGE To get the memcached container image on your local system, run the following: - docker pull hub.docker.io/phracek/memcached + docker pull registry.fedoraproject.org/f26/memcached # ENVIRONMENT VARIABLES The memcached container includes the following environment variables: -CACHE_SIZE=128 - The variable sets size of cached used by memcached. +For turn on verbose mode, use environment variable +-e MEMCACHED_DEBUG_MODE + +For setting cache size, use environment variable +-e MEMCACHED_CACHE_SIZE + +For setting maximum connections, use environment variable +-e MEMCACHED_CONNECTIONS + +For setting maximum threads, use environment variable +-e MEMCACHED_THREADS # SECURITY IMPLICATIONS Lists of security-related attributes that are opened to the host.