Is there a way to block connections to a container from outside its docker-compose parameters?


So I have four servers that run an instance of a Docker image on each of them. I have been asked to deploy a Memcache image, link it to the instances by adding it inside the docker-compose.yml file, and to make sure that the Memcache container does not accept connections from outside.

Basically, my docker-compose.yml looks like so:

“` version: '2'

services: web: depends_on: – mysql ports: – 8080:80`

mysql: image: mysql:5.7 ports: – 3306:3306`

memcached: image: memcached depends_on: – web

How can I make sure that when running telnet from outside the containers, I will get a connection refused but not when running telnet memcached:11211 from inside the web container?

Thank you in advance.

submitted by /u/Jaeger767
[link] [comments]
Source: Reddit