i'm trying to get a connection between 2 Docker container. The first one is a postgres database and the second one is a jboss.
I'm using ansible and here is my Playbook:
---
- hosts: localhost
tasks:
- name: start postgresql
docker:
name: mypostgres
image: MYIMAGE_POSTGRES
ports:
- 5432:5432
expose:
- 5432:5432
state: started
env:
DB_USER: "user"
DB_PASS: "pass"
DB_NAME: "name"
- name: start jboss
docker:
name: jboss
image: MYIMAGE_JBOSS
ports:
- 1099:1099
expose:
- 1099:1099
state: running
env:
POSTGRES_PORT_5432_TCP_ADDR: "172.17.0.2"
POSTGRES_PORT_5432_TCP_PORT: 5432
HIBERNATE_CREATE_DDL: ""
DB_NAME: "name"
DB_USER: "user"
DB_PASS: "pass"
If i start both docker images, there is no connection between database and jboss. Is there anything i had missed, in my configuration?
Thanks a lot, Pascal
You need to link the postgres container to the jboss one. For doing that, use the link
option
...
docker:
name: jboss
image: MYIMAGE_JBOSS
ports:
- 1099:1099
expose:
- 1099:1099
links:
-mypostgres
state: running
env:
POSTGRES_PORT_5432_TCP_ADDR: "mypostgres"
POSTGRES_PORT_5432_TCP_PORT: 5432
HIBERNATE_CREATE_DDL: ""
DB_NAME: "name"
DB_USER: "user"
DB_PASS: "pass"
...
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments