Coder Social home page Coder Social logo

Comments (2)

Godin avatar Godin commented on July 29, 2024 1

@IAPOLINARIO
when containers linked they can communicate internally without expose of any ports - see "Communication across links" at https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/
and

   ports:
     - "5433:5432"

affects how port will published and not how it will be visible for linked container.

So that using

$ docker images
REPOSITORY          TAG                       IMAGE ID            CREATED             SIZE
sonarqube           latest                    334aa4aa378e        8 days ago          780.4 MB
postgres            latest                    247a11721cbd        2 weeks ago         265.9 MB

$ docker --version        
Docker version 1.11.0, build 4dc5990

$ docker-compose --version
docker-compose version: 1.5.1

with docker-compose.yml

sonarqube:
   image: sonarqube
   ports:
   - "19000:9000"
   - "19092:9092"
   links:
     - sonardb
   environment:
      - SONARQUBE_JDBC_URL=jdbc:postgresql://sonardb:5432/sonar

sonardb:
   image: postgres:latest
   ports:
     - "5433:5432"
   environment:
     - POSTGRES_USER=sonar
     - POSTGRES_PASSWORD=sonar

works as expected - SonarQube communicates with PostgreSQL using port 5432 which is published for the all other world as 5433.

from docker-sonarqube.

IAPOLINARIO avatar IAPOLINARIO commented on July 29, 2024

Uowwww...That's great! I've read about the containers link, but i didn't realize that the communication occurs internally and the port mapping it's just to externally world. This scenario it's a little trick.

I spent all day trying to connect to Postgres and my last move was make a post here. Thank's a lot!

I made the change in my docker-compose.yml and works perfectly!

PS - Using

depends_on

works in the same way.

from docker-sonarqube.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.