Docker, pylibmc, memcached Docker, pylibmc, memcached docker docker

Docker, pylibmc, memcached


You have two options. Installing it within your app container or install memcached as isolated container.

OPTION 1

You can add a command to install libmemcached on your app's Dockerfile.

If you are using some kind of ubuntu based image or alpine

Just add

RUN apt-get update && apt-get install -y \        libmemcached11 \        libmemcachedutil2 \        libmemcached-dev \        libz-dev

Then, you can do pip install pylibmc

OPTION 2

You can add memcached as a separated container. Just add in your docker-compose

memcached:  image: memcached  ports:    - "11211:11211"

Of course, you need to link your app container with memcached container.


The easiest way to solve this problem is to update the Dockerfile for the app and install the development dependencies required to build the python package.

On ubuntu/debian that might be something like:

apt-get install libmemcached-dev gcc python-dev

A second (more advantaged) option is to build a wheel for this package in a separate container, then install the wheel instead of the source tarball. That way you don't have to install any other packages, and your final image will be much smaller. However it requires more work to setup.