0

I've a docker host & mariadb container in it and I want to apply a replication between this container and another server on another provider

using the following example below I was able to connect remotely to the container but the port is open to the world which I don't recommend

here is my docker-compose.yml file :

db02:
  build: .
  dockerfile: db02/Dockerfile
  container_name: db02
  dns:
    - 8.8.8.8
    - 8.8.4.4
  hostname: db02.local
  env_file:
    - db02/env
  ports:
    - "3306:3306"  

my question is how do I open mysql port to one ip & block it for all others , is there any thing like allow / deny in docker-compose?

tawfekov
  • 195
  • 8

1 Answers1

0

You're more dynamic when you use iptables to secure your connection:

iptables -A INPUT -p tcp --dport 3306 -s 1.2.3.4 -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -j DROP
Patrick
  • 71
  • 8
  • thanks but I'm looking for docker/docker-compose specific way to do it , so it will completely managed by docker – tawfekov Jan 28 '17 at 16:07