Memcached multi instances

Hello @cytopia

I want to configure my docker stack to use memcached as a cluster with at least two nodes (servers).
I don’t know how to configure it correctly. My issue occured at the bind step.

i’ve added in my docker-compose.overwrite.yml the following code

  memcd2:
    image: memcached:${MEMCD_SERVER}
    hostname: memcd2

    ports:
      # [local-machine:]local-port:docker-port
      - "${LOCAL_LISTEN_ADDR}${HOST_PORT_MEMCD}:11211"

    networks:
      app_net:
        ipv4_address: 172.16.238.25

    volumes:
      # ---- Format: ----
      # HOST-DIRECTORY : DOCKER-DIRECTORY

      # Mount logs
      - ${DEVILBOX_PATH}/log/memcd-${MEMCD_SERVER}:/var/log/memcd:rw${MOUNT_OPTIONS}

    depends_on:
      - bind
      - php
      - httpd

I’ve only change the ipv4 address of the second node (default is 172.16.238.15)

Thanks in advance
Laurent

What issue has occured?

Something like that

ERROR: for memcd_2  Cannot start service memcd_2: driver failed programming external connectivity on endpoint devilbox_memcd_2_1 (ae424895eb003877e38e6b82d8c771b96021daea9d016e407621e4d6f8515f63): Bind for 0.0.0.0:11211 failed: port is already allocated

PHP with Memcached allow to use multiple configuration/servers on same port

http://fr.php.net/manual/en/memcached.addserver.php#refsect1-memcached.addserver-examples

You can use the same port, but then you should not expose to the same port. Both memcd and memcd2 try to bind to 11211 on the host system which is not allowed, as only always one program can use one port.

Thanks again for your review @cytopia . My bad, or just a little sleep missing :wink: