3

I have an app within a docker container(ip: 172.17.42.1) on a server(ip: 192.168.1.8), and mysql database is on another server(ip: 192.108.1.19).

Tallmad
  • 1,951
  • 4
  • 22
  • 29
  • 2
    IMO in default configuration, you should be able to reach the database server from container. – Jiri Feb 27 '14 at 05:43
  • @Jiri is correct, your container has network access. If the host can reach the database server, the container can as well (all local firewall rules aside) – Ben Whaley Feb 27 '14 at 06:20
  • @jiri thanks,guys。It failed last time, but just now it succeeded. I'll close the question. – Tallmad Feb 27 '14 at 06:38

1 Answers1

0

You can connect to other docker containers using this command:

docker run -d -p [port:[port_no]--link [db_container] \
  -e DATABASE_URL=[web_address / ip] \ [image_name]
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
Sergiu
  • 2,928
  • 3
  • 27
  • 37