Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Petr "Stone" Hracek
b72afda511 Update container image according to Fedora-Dockerfiles 2017-09-06 12:35:29 +02:00
4 changed files with 104 additions and 98 deletions

View file

@ -12,10 +12,10 @@ LABEL MAINTAINER "Petr Hracek" <phracek@redhat.com>
LABEL summary="High Performance, Distributed Memory Object Cache" \ LABEL summary="High Performance, Distributed Memory Object Cache" \
name="$FGC/$NAME" \ name="$FGC/$NAME" \
version="0" \ version="0" \
release="1.$DISTTAG" \ release="2.$DISTTAG" \
architecture="$ARCH" \ architecture="$ARCH" \
com.redhat.component=$NAME \ 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." \ 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." \ 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." \ 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." \

View file

@ -2,83 +2,52 @@
Memcached is High Performance, Distributed Memory Object Cache Memcached is High Performance, Distributed Memory Object Cache
## Summary ## How to use the container
- Dockerfile - build container image with memcached. Pull the image from Docker Hub:
- openshift-template.yml - Template for OpenShift to memcached.
## How to use the container over standard 11211 port
Command for running memcached docker container:
```bash ```bash
docker run -it -e CACHE_SIZE=128 \ $ sudo docker pull registry.fedoraproject.org/f26/memcached
-p 11211:11211
``` ```
If you would like to increase a CACHE_SIZE use environment variable -e CACHE_SIZE: Run the container
```bash ```bash
docker run -it -e CACHE_SIZE=128 \ docker run -it -p 11211:11211 --name memcached registry.fedoraproject.org/f26/memcached
-p 11211:11211
``` ```
## How to run memcached as standalone container If you would like to debug memcached, use container option =e MEMCACHED_DEBUG_MODE:
Copy memcached-container.service to ```/usr/lib/systemd/user/``` directory
```bash ```bash
sudo cp memcached-container.service /usr/lib/systemd/user/ docker run -it -p 11211:11211
systemctl --user daemon-reload [-e MEMCACHED_DEBUG_MODE]
--name memcached registry.fedoraproject.org/f26/memcached
``` ```
Command for running memcached as standalone container: 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 ```bash
systemctl start --user memcached-container docker run -it -p 11211:11211
[-e MEMCACHED_CACHE_SIZE=<size_in_MB>]
[-e MEMCACHED_CONNECTIONS=<max_simultaneous_connections>]
[-e MEMCACHED_THREADS=<max_concurrent_threads>]
--name memcached registry.fedoraproject.org/f26/memcached
``` ```
## How to stop memcached as standalone container ## A demo
Command for stopping memcached as standalone container:
Here is a simple demo how to run memcached
* Copy systemd service which will take care of memcached container:
```bash ```bash
systemctl stop --user memcached-container $ sudo cp -av memcached-container.service /usr/lib/systemd/system/
$ sudo systemctl daemon-reload
``` ```
## How to test the memcached
Commands for testing memcached docker container: * We can start memcached now:
To store data in memcached server with telnet:
```bash ```bash
set KEY META_DATA EXPIRY_TIME LENGTH_IN_BYTES $ sudo systemctl start memcached-container
``` ```
To get data * You should be able to test memcached by commands (taken from http://www.journaldev.com/16/memcached-telnet-commands-with-example):
```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 ```bash
set Test 0 100 10 set Test 0 100 10
JournalDev JournalDev
@ -110,3 +79,8 @@ version
VERSION 1.4.25 VERSION 1.4.25
quit quit
``` ```
## Repository structure
- Dockerfile - build container image with memcached.
- openshift-template.yml - Template for OpenShift to memcached.

23
files/memcached.sh Executable file
View file

@ -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

17
help.md
View file

@ -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. 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: The container itself consists of:
- fedora/24 base image - fedora/f26 base image
- memcached RPM package - memcached RPM package
Files added to the container during docker build include: /files/memcached.sh 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 # USAGE
To get the memcached container image on your local system, run the following: 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 # ENVIRONMENT VARIABLES
The memcached container includes the following environment variables: The memcached container includes the following environment variables:
CACHE_SIZE=128 For turn on verbose mode, use environment variable
The variable sets size of cached used by memcached. -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 # SECURITY IMPLICATIONS
Lists of security-related attributes that are opened to the host. Lists of security-related attributes that are opened to the host.