Skip to content

Instantly share code, notes, and snippets.

@neerolyte
Last active March 20, 2020 17:29
Show Gist options
  • Save neerolyte/d62fec59267568c3b9a4936f6f513381 to your computer and use it in GitHub Desktop.
Save neerolyte/d62fec59267568c3b9a4936f6f513381 to your computer and use it in GitHub Desktop.
Using Docker for development of memcached

This is not a complete, comprehensive guide, but it is meant to be a start in the right direction.

From the memcached working directory (where ever you cloned the repo):

$ docker run -it -v "$PWD:/memcached" --name "memcache-dev" ubuntu:artful bash

This creates a container named "memcache-dev" based on the artful tag of the ubuntu image from hub.docker.com.

To stop the container, simply exit the bash shell the first time.

To restart the container: $ docker start memcache-dev

To start a shell in the container: $ docker exec -it memcache-dev bash

To stop the container normally: $ docker stop memcache-dev

To remove the container permanently: $ docker rm -v memcache-dev

From within the container the code is mounted at /memcached:

root@04eb3d457d46:/# cd /memcached/
root@04eb3d457d46:/memcached#

We need a few packages installed:

root@04eb3d457d46:/memcached# apt-get update
[...]
root@04eb3d457d46:/memcached# apt-get install make git autotools-dev automake gcc libevent-dev
[...]

Now run the memcached configury type stuff (can you tell I'm not a C programmer?):

root@04eb3d457d46:/memcached# ./autogen.sh
[...]
root@04eb3d457d46:/memcached# ./configure

make and make test should now both work:

root@04eb3d457d46:/memcached# make && make test
make  all-recursive
make[1]: Entering directory '/memcached'
Making all in doc
make[2]: Entering directory '/memcached/doc'
make  all-am
make[3]: Entering directory '/memcached/doc'
make[3]: Nothing to be done for 'all-am'.
[...]
t/stats-conns.t ............. ok
t/stats-detail.t ............ ok
t/stats.t ................... ok
t/touch.t ................... ok
t/udp.t ..................... ok
t/unixsocket.t .............. ok
t/watcher.t ................. ok
t/whitespace.t .............. ok
All tests successful.
Files=59, Tests=25858, 210 wallclock secs ( 5.12 usr  0.48 sys + 10.41 cusr  8.28 csys = 24.29 CPU)
Result: PASS
File 'assoc.c' Lines executed:42.98% of 121 Creating 'assoc.c.gcov' File '/usr/include/stdlib.h' Lines executed:0.00% of 1 Creating 'stdlib.h.gcov' File '/usr/include/x86_64-linux-gnu/bits/stdio2.h' Lines executed:0.00% of 1 Creating 'stdio2.h.gcov'
[...]
File 'util.c' Lines executed:78.02% of 91 Creating 'util.c.gcov' File '/usr/include/x86_64-linux-gnu/bits/stdio2.h' Lines executed:100.00% of 2 Creating 'stdio2.h.gcov' File '/usr/include/x86_64-linux-gnu/bits/string3.h' Lines executed:100.00% of 1 Creating 'string3.h.gcov'
root@04eb3d457d46:/memcached#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment