Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
1,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. I would like my docker containers connect and use databases in remote host in different machine. I am not using any orchestration tool like docker swarm or kubernetes. Instead, I am simply using docker-compose becuase I don't have many containers. Here is an example of docker-compose I am using:
  2.  
  3.  
  4. version: "3.7"
  5.  
  6. services:
  7.  
  8. core:
  9.  
  10. image: myrepo/core:latest
  11.  
  12. ports:
  13.  
  14. - 8080:8080
  15.  
  16. networks:
  17.  
  18. - backend
  19.  
  20. restart: always
  21.  
  22. extra_hosts:
  23.  
  24. - 'mongodb: 192.168.2.50'
  25.  
  26. - 'postgresdb:192.168.2.50'
  27.  
  28. depends_on:
  29.  
  30. - mongodb
  31.  
  32. - postgresdb
  33.  
  34.  
  35.  
  36. event:
  37.  
  38. image: myrepo/event:latest
  39.  
  40. ports:
  41.  
  42. - 8081:8081
  43.  
  44. networks:
  45.  
  46. - backend
  47.  
  48. restart: always
  49.  
  50. extra_hosts:
  51.  
  52. - 'mongodb: 192.168.2.50'
  53.  
  54. - 'postgresdb:192.168.2.50'
  55.  
  56. depends_on:
  57.  
  58. - mongodb
  59.  
  60. - postgresdb
  61.  
  62.  
  63.  
  64. IP of remote server: 192.168.2.50
  65.  
  66.  
  67.  
  68. I tried using extra_hosts option but this doesn't solve my problem. What other options are available to make this work? IP of the docker host has been whitelisted and necessary ports are open in the database server firewall to give access to the docker host.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement