Docker, pylibmc, memcached
<p>I've project that uses memcached. So when docker trying to "pip install pylibmc", library can't find libmemcached cause it's not installed yet. How can I organise my docker-compose.yml, or maybe I have to do something with dockerfile?</p>

<p>Now my docker-compose.yml looks like (I've deleted memcached container lines):</p>

<pre><code>version: '2'
    services:

      app:
        build: .
        volumes:
          - ./app:/usr/src/app
          - ./logs:/var/log
        expose:
          - "8000"
        links:
          - db:db
        networks:
          tickets-api:
            ipv4_address: 172.25.0.100
        extra_hosts:
          - "db:172.25.0.102"

      webserver:
        image: nginx:latest
        links:
          - app
          - db
        volumes_from:
          - app
        volumes:
          - ./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
          - ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
        ports:
          - "80:80"
        networks:
          tickets-api:
            ipv4_address: 172.25.0.101

      db:
        restart: always
        image: postgres
        volumes:
          - ./postgresql/pgdata:/pgdata
        ports:
          - "5432:5432"
        environment:
          - POSTGRES_USER=postgres
          - POSTGRES_PASSWORD=postgres
          - PGDATA=/pgdata
        networks:
          tickets-api:
            ipv4_address: 172.25.0.102

    networks:
      tickets-api:
        driver: bridge
        ipam:
          config:
          - subnet: 172.25.0.0/24
</code></pre>

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

<p><strong>OPTION 1</strong></p>

<p>You can add a command to install <code>libmemcached</code> on your app's <code>Dockerfile</code>. </p>

<p>If you are using some kind of ubuntu based image or alpine</p>

<p>Just add</p>

<pre><code>RUN apt-get update &amp;&amp; apt-get install -y \
        libmemcached11 \
        libmemcachedutil2 \
        libmemcached-dev \
        libz-dev
</code></pre>

<p>Then, you can do <code>pip install pylibmc</code></p>

<p><strong>OPTION 2</strong></p>

<p>You can add memcached as a separated container. Just add in your docker-compose</p>

<pre><code>memcached:
  image: memcached
  ports:
    - "11211:11211"
</code></pre>

<p>Of course, you need to link your app container with memcached container. </p>

python docker memcached docker-compose pylibmc