title: How to start two memcached instances on two different ports from docker-compose?
body: <p>I want to start two docker-compose services of memcached. I am using the docker standard memcached image for both instances. Memcached should be able to use environment variables to change the port it is listening on, but it does not seem to work.</p>
  
  <p>My docker-compose.yml</p>
  
  <pre><code>...
  memcached-server:
      image: memcached
      environment:
        MEMCACHED_PORT: 11211
      ports:
        - 11311:11211
      networks:
        - my_net
  
  memcached-server-lock:
      image: memcached
      environment:
        MEMCACHED_PORT: 11212
        MEMCACHED_CACHE_SIZE: 128
      ports:
        - 11312:11212
      networks:
        - my_net
  ...
  </code></pre>
  
  <p>The containers are starting correctly but the env variables do not seem to be picked up:</p>
  
  <pre><code>0ae76227b72b        memcached                            "docker-entrypoint..."   17 seconds ago      Up 13 seconds       0.0.0.0:11311-&gt;11211/tcp mobidesk_memcached-server_1
  ab3682361dad        memcached                            "docker-entrypoint..."   17 seconds ago      Up 12 seconds       11211/tcp, 0.0.0.0:11312-&gt;11212/tcp  mobidesk_memcached-server-lock_1
  </code></pre>
  
  <p>Does anybody know which variables to use. Or is it something else I missed?</p>