Network connection between 2 Docker Container (JBOSS/DATABASE)

Pascal G

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

Camilo Silva

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Docker container Network connection between different host

From Dev

Connection issue between Docker container and Other machine

From Dev

Jenkins: connection between docker container with jenkins master and docker container with jenkins slave

From Dev

Connection refused on docker container

From Dev

Docker container not exposed on network

From Dev

connection between 2 docker containers using docker compose

From Dev

IO Error: The Network Adapter could not establish the connection when running oracle DB as docker container

From Dev

Connection refused on nginx docker container

From Dev

docker cannot specify container connection

From Dev

Slow network performance in Docker container

From Dev

Docker container as network gateway [Not responding]

From Dev

How does network communication between 2 Docker Containers work?

From Dev

How to get ssh connection with docker container on OSX(boot2docker)

From Dev

How do I connect a Docker container running in boot2docker to a network service running on another host?

From Dev

Difference between Docker container and service

From Dev

Network communication between Docker images

From Dev

How to make a TCP outgoing connection with Docker container?

From Dev

Docker container nodejs connection to external mysql fail

From Dev

No internet connection at docker container running on ubuntu server

From Dev

WP Docker container fails Connection Error: (2002)

From Dev

connection between 2 namespaces

From Dev

Connection between 2 components

From Java

Is there a difference between "docker ps" and "docker container ls"?

From Dev

docker container network/DNS/Firewall issue

From Dev

Ping Docker Container from another machine in the network

From Dev

Not able to connect to network inside docker container

From Dev

Cannot connect Docker container to Weave network

From Dev

Connecting Docker Container running on bridge network to Localhost

From Dev

docker container network/DNS/Firewall issue

Related Related

  1. 1

    Docker container Network connection between different host

  2. 2

    Connection issue between Docker container and Other machine

  3. 3

    Jenkins: connection between docker container with jenkins master and docker container with jenkins slave

  4. 4

    Connection refused on docker container

  5. 5

    Docker container not exposed on network

  6. 6

    connection between 2 docker containers using docker compose

  7. 7

    IO Error: The Network Adapter could not establish the connection when running oracle DB as docker container

  8. 8

    Connection refused on nginx docker container

  9. 9

    docker cannot specify container connection

  10. 10

    Slow network performance in Docker container

  11. 11

    Docker container as network gateway [Not responding]

  12. 12

    How does network communication between 2 Docker Containers work?

  13. 13

    How to get ssh connection with docker container on OSX(boot2docker)

  14. 14

    How do I connect a Docker container running in boot2docker to a network service running on another host?

  15. 15

    Difference between Docker container and service

  16. 16

    Network communication between Docker images

  17. 17

    How to make a TCP outgoing connection with Docker container?

  18. 18

    Docker container nodejs connection to external mysql fail

  19. 19

    No internet connection at docker container running on ubuntu server

  20. 20

    WP Docker container fails Connection Error: (2002)

  21. 21

    connection between 2 namespaces

  22. 22

    Connection between 2 components

  23. 23

    Is there a difference between "docker ps" and "docker container ls"?

  24. 24

    docker container network/DNS/Firewall issue

  25. 25

    Ping Docker Container from another machine in the network

  26. 26

    Not able to connect to network inside docker container

  27. 27

    Cannot connect Docker container to Weave network

  28. 28

    Connecting Docker Container running on bridge network to Localhost

  29. 29

    docker container network/DNS/Firewall issue

HotTag

Archive