The well-known 'Docker containers don't see each other' problem Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to list containers in DockerHow to remove old Docker containersCopying files from Docker container to hostCopying files from host to Docker containerWhat is the difference between a Docker image and a container?From inside of a Docker container, how do I connect to the localhost of the machine?Docker Compose: Avoid recreation of data containerDocker link container as build argumenthow to access mysql docker container in spring boot docker containerConnection refused between containers: Docker

How to tell that you are a giant?

Did Deadpool rescue all of the X-Force?

Project Euler #1 in C++

Does lack of seasonality imply random time series?

What is the font for "b" letter?

Did Krishna say in Bhagavad Gita "I am in every living being"

How can I reduce the gap between left and right of cdot with a macro?

Question about debouncing - delay of state change

Using audio cues to encourage good posture

Sum letters are not two different

Is there a kind of relay only consumes power when switching?

Is there hard evidence that the grant peer review system performs significantly better than random?

How to write the following sign?

How fail-safe is nr as stop bytes?

How to install press fit bottom bracket into new frame

Amount of permutations on an NxNxN Rubik's Cube

Localisation of Category

Why should I vote and accept answers?

Performance gap between bool std:vector and array

An adverb for when you're not exaggerating

How do I use the new nonlinear finite element in Mathematica 12 for this equation?

What does it mean that physics no longer uses mechanical models to describe phenomena?

Most bit efficient text communication method?

Hangman Game with C++



The well-known 'Docker containers don't see each other' problem



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to list containers in DockerHow to remove old Docker containersCopying files from Docker container to hostCopying files from host to Docker containerWhat is the difference between a Docker image and a container?From inside of a Docker container, how do I connect to the localhost of the machine?Docker Compose: Avoid recreation of data containerDocker link container as build argumenthow to access mysql docker container in spring boot docker containerConnection refused between containers: Docker



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I checked many forum entries (e.g. in stackoverflow too) but I still cannot figure out what the problem is with my docker-compose file.



So when I start my application (content-app) I got the following exception:



Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=content-database)(port=3306)(type=master) : Connection refused (Connection refused)


My application is a Spring boot app that tries to connect to the database, the JDBC URL is



url: jdbc:mariadb://content-database:3306/contentdb?autoReconnect=true


The Spring Boot app works fine as locally (when no docker is used) can connect to the local mariadb.

So the content-app container don't see the content-database container. I read that if I specify a network and I assign the containers to the network then they should be able to connect to each other.



When I connect to the running content-app container then I can telnet to content-database



root@894628d7bdd9:/# telnet content-database 3306
Trying 172.28.0.3...
Connected to content-database.
Escape character is '^]'.
n
5.5.5-10.4.3-MariaDB-1:10.4.3+maria~bionip/4X@wW/�#_9<b[~)N.:ymysql_native_passwordConnection closed by foreign host.


My docker-compose yaml file:



version: '3.3'
networks:
net_content:
services:
content-database:
image: content-database:latest
build:
context: .
dockerfile: ./database/Dockerfile
networks:
- net_content
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
content-redis:
image: content-redis:latest
build:
context: .
dockerfile: ./redis/Dockerfile
networks:
- net_content
content-app:
image: content-app:latest
build:
context: .
dockerfile: ./content/Dockerfile
networks:
- net_content
depends_on:
- "content-database"


Any hint please?

Thanks!










share|improve this question






























    0















    I checked many forum entries (e.g. in stackoverflow too) but I still cannot figure out what the problem is with my docker-compose file.



    So when I start my application (content-app) I got the following exception:



    Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=content-database)(port=3306)(type=master) : Connection refused (Connection refused)


    My application is a Spring boot app that tries to connect to the database, the JDBC URL is



    url: jdbc:mariadb://content-database:3306/contentdb?autoReconnect=true


    The Spring Boot app works fine as locally (when no docker is used) can connect to the local mariadb.

    So the content-app container don't see the content-database container. I read that if I specify a network and I assign the containers to the network then they should be able to connect to each other.



    When I connect to the running content-app container then I can telnet to content-database



    root@894628d7bdd9:/# telnet content-database 3306
    Trying 172.28.0.3...
    Connected to content-database.
    Escape character is '^]'.
    n
    5.5.5-10.4.3-MariaDB-1:10.4.3+maria~bionip/4X@wW/�#_9<b[~)N.:ymysql_native_passwordConnection closed by foreign host.


    My docker-compose yaml file:



    version: '3.3'
    networks:
    net_content:
    services:
    content-database:
    image: content-database:latest
    build:
    context: .
    dockerfile: ./database/Dockerfile
    networks:
    - net_content
    restart: always
    environment:
    MYSQL_ROOT_PASSWORD: root
    content-redis:
    image: content-redis:latest
    build:
    context: .
    dockerfile: ./redis/Dockerfile
    networks:
    - net_content
    content-app:
    image: content-app:latest
    build:
    context: .
    dockerfile: ./content/Dockerfile
    networks:
    - net_content
    depends_on:
    - "content-database"


    Any hint please?

    Thanks!










    share|improve this question


























      0












      0








      0








      I checked many forum entries (e.g. in stackoverflow too) but I still cannot figure out what the problem is with my docker-compose file.



      So when I start my application (content-app) I got the following exception:



      Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=content-database)(port=3306)(type=master) : Connection refused (Connection refused)


      My application is a Spring boot app that tries to connect to the database, the JDBC URL is



      url: jdbc:mariadb://content-database:3306/contentdb?autoReconnect=true


      The Spring Boot app works fine as locally (when no docker is used) can connect to the local mariadb.

      So the content-app container don't see the content-database container. I read that if I specify a network and I assign the containers to the network then they should be able to connect to each other.



      When I connect to the running content-app container then I can telnet to content-database



      root@894628d7bdd9:/# telnet content-database 3306
      Trying 172.28.0.3...
      Connected to content-database.
      Escape character is '^]'.
      n
      5.5.5-10.4.3-MariaDB-1:10.4.3+maria~bionip/4X@wW/�#_9<b[~)N.:ymysql_native_passwordConnection closed by foreign host.


      My docker-compose yaml file:



      version: '3.3'
      networks:
      net_content:
      services:
      content-database:
      image: content-database:latest
      build:
      context: .
      dockerfile: ./database/Dockerfile
      networks:
      - net_content
      restart: always
      environment:
      MYSQL_ROOT_PASSWORD: root
      content-redis:
      image: content-redis:latest
      build:
      context: .
      dockerfile: ./redis/Dockerfile
      networks:
      - net_content
      content-app:
      image: content-app:latest
      build:
      context: .
      dockerfile: ./content/Dockerfile
      networks:
      - net_content
      depends_on:
      - "content-database"


      Any hint please?

      Thanks!










      share|improve this question
















      I checked many forum entries (e.g. in stackoverflow too) but I still cannot figure out what the problem is with my docker-compose file.



      So when I start my application (content-app) I got the following exception:



      Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=content-database)(port=3306)(type=master) : Connection refused (Connection refused)


      My application is a Spring boot app that tries to connect to the database, the JDBC URL is



      url: jdbc:mariadb://content-database:3306/contentdb?autoReconnect=true


      The Spring Boot app works fine as locally (when no docker is used) can connect to the local mariadb.

      So the content-app container don't see the content-database container. I read that if I specify a network and I assign the containers to the network then they should be able to connect to each other.



      When I connect to the running content-app container then I can telnet to content-database



      root@894628d7bdd9:/# telnet content-database 3306
      Trying 172.28.0.3...
      Connected to content-database.
      Escape character is '^]'.
      n
      5.5.5-10.4.3-MariaDB-1:10.4.3+maria~bionip/4X@wW/�#_9<b[~)N.:ymysql_native_passwordConnection closed by foreign host.


      My docker-compose yaml file:



      version: '3.3'
      networks:
      net_content:
      services:
      content-database:
      image: content-database:latest
      build:
      context: .
      dockerfile: ./database/Dockerfile
      networks:
      - net_content
      restart: always
      environment:
      MYSQL_ROOT_PASSWORD: root
      content-redis:
      image: content-redis:latest
      build:
      context: .
      dockerfile: ./redis/Dockerfile
      networks:
      - net_content
      content-app:
      image: content-app:latest
      build:
      context: .
      dockerfile: ./content/Dockerfile
      networks:
      - net_content
      depends_on:
      - "content-database"


      Any hint please?

      Thanks!







      docker docker-compose






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 22 at 10:27







      Viktor

















      asked Mar 22 at 10:03









      ViktorViktor

      65221130




      65221130






















          2 Answers
          2






          active

          oldest

          votes


















          0














          I guess MariaDB is listening on default port 3307, this means your application has to connect to this port as well. I guess this is the case as you are mapping the port 3307 of your container to "the outside".



          Change the port in your connection string:



          url: jdbc:mariadb://content-database:3307/contentdb?autoReconnect=true





          share|improve this answer

























          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27


















          0














          You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile






          share|improve this answer

























          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27











          • So on which port is content-database listening? And do you expose that port in the Dockerfile?

            – codinghaus
            Mar 22 at 10:33











          • It is the standard 3306. It is exposed there

            – Viktor
            Mar 22 at 10:50











          • Okay, of what kind (driver) is the net_content?

            – codinghaus
            Mar 22 at 10:53












          • It is a bridge.

            – Viktor
            Mar 22 at 11:11











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55297190%2fthe-well-known-docker-containers-dont-see-each-other-problem%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I guess MariaDB is listening on default port 3307, this means your application has to connect to this port as well. I guess this is the case as you are mapping the port 3307 of your container to "the outside".



          Change the port in your connection string:



          url: jdbc:mariadb://content-database:3307/contentdb?autoReconnect=true





          share|improve this answer

























          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27















          0














          I guess MariaDB is listening on default port 3307, this means your application has to connect to this port as well. I guess this is the case as you are mapping the port 3307 of your container to "the outside".



          Change the port in your connection string:



          url: jdbc:mariadb://content-database:3307/contentdb?autoReconnect=true





          share|improve this answer

























          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27













          0












          0








          0







          I guess MariaDB is listening on default port 3307, this means your application has to connect to this port as well. I guess this is the case as you are mapping the port 3307 of your container to "the outside".



          Change the port in your connection string:



          url: jdbc:mariadb://content-database:3307/contentdb?autoReconnect=true





          share|improve this answer















          I guess MariaDB is listening on default port 3307, this means your application has to connect to this port as well. I guess this is the case as you are mapping the port 3307 of your container to "the outside".



          Change the port in your connection string:



          url: jdbc:mariadb://content-database:3307/contentdb?autoReconnect=true






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 22 at 10:18

























          answered Mar 22 at 10:12









          BeheBehe

          4,79532336




          4,79532336












          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27

















          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27
















          Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

          – Viktor
          Mar 22 at 10:27





          Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

          – Viktor
          Mar 22 at 10:27













          0














          You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile






          share|improve this answer

























          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27











          • So on which port is content-database listening? And do you expose that port in the Dockerfile?

            – codinghaus
            Mar 22 at 10:33











          • It is the standard 3306. It is exposed there

            – Viktor
            Mar 22 at 10:50











          • Okay, of what kind (driver) is the net_content?

            – codinghaus
            Mar 22 at 10:53












          • It is a bridge.

            – Viktor
            Mar 22 at 11:11















          0














          You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile






          share|improve this answer

























          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27











          • So on which port is content-database listening? And do you expose that port in the Dockerfile?

            – codinghaus
            Mar 22 at 10:33











          • It is the standard 3306. It is exposed there

            – Viktor
            Mar 22 at 10:50











          • Okay, of what kind (driver) is the net_content?

            – codinghaus
            Mar 22 at 10:53












          • It is a bridge.

            – Viktor
            Mar 22 at 11:11













          0












          0








          0







          You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile






          share|improve this answer















          You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 22 at 10:47

























          answered Mar 22 at 10:12









          codinghauscodinghaus

          1,042517




          1,042517












          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27











          • So on which port is content-database listening? And do you expose that port in the Dockerfile?

            – codinghaus
            Mar 22 at 10:33











          • It is the standard 3306. It is exposed there

            – Viktor
            Mar 22 at 10:50











          • Okay, of what kind (driver) is the net_content?

            – codinghaus
            Mar 22 at 10:53












          • It is a bridge.

            – Viktor
            Mar 22 at 11:11

















          • Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

            – Viktor
            Mar 22 at 10:27











          • So on which port is content-database listening? And do you expose that port in the Dockerfile?

            – codinghaus
            Mar 22 at 10:33











          • It is the standard 3306. It is exposed there

            – Viktor
            Mar 22 at 10:50











          • Okay, of what kind (driver) is the net_content?

            – codinghaus
            Mar 22 at 10:53












          • It is a bridge.

            – Viktor
            Mar 22 at 11:11
















          Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

          – Viktor
          Mar 22 at 10:27





          Sorry, my fault I forgot to remove the ports declaration, it is not in the yaml file.

          – Viktor
          Mar 22 at 10:27













          So on which port is content-database listening? And do you expose that port in the Dockerfile?

          – codinghaus
          Mar 22 at 10:33





          So on which port is content-database listening? And do you expose that port in the Dockerfile?

          – codinghaus
          Mar 22 at 10:33













          It is the standard 3306. It is exposed there

          – Viktor
          Mar 22 at 10:50





          It is the standard 3306. It is exposed there

          – Viktor
          Mar 22 at 10:50













          Okay, of what kind (driver) is the net_content?

          – codinghaus
          Mar 22 at 10:53






          Okay, of what kind (driver) is the net_content?

          – codinghaus
          Mar 22 at 10:53














          It is a bridge.

          – Viktor
          Mar 22 at 11:11





          It is a bridge.

          – Viktor
          Mar 22 at 11:11

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55297190%2fthe-well-known-docker-containers-dont-see-each-other-problem%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해