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;
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
add a comment |
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
add a comment |
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
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
docker docker-compose
edited Mar 22 at 10:27
Viktor
asked Mar 22 at 10:03
ViktorViktor
65221130
65221130
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
add a comment |
You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
So on which port iscontent-databaselistening? 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 thenet_content?
– codinghaus
Mar 22 at 10:53
It is a bridge.
– Viktor
Mar 22 at 11:11
|
show 2 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
add a comment |
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
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
add a comment |
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
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
edited Mar 22 at 10:18
answered Mar 22 at 10:12
BeheBehe
4,79532336
4,79532336
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
add a comment |
Sorry, my fault I forgot to remove theportsdeclaration, 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
add a comment |
You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
So on which port iscontent-databaselistening? 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 thenet_content?
– codinghaus
Mar 22 at 10:53
It is a bridge.
– Viktor
Mar 22 at 11:11
|
show 2 more comments
You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
So on which port iscontent-databaselistening? 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 thenet_content?
– codinghaus
Mar 22 at 10:53
It is a bridge.
– Viktor
Mar 22 at 11:11
|
show 2 more comments
You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile
You have to expose the port on which content-database is listening in the Dockerfile at ./database/Dockerfile
edited Mar 22 at 10:47
answered Mar 22 at 10:12
codinghauscodinghaus
1,042517
1,042517
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
So on which port iscontent-databaselistening? 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 thenet_content?
– codinghaus
Mar 22 at 10:53
It is a bridge.
– Viktor
Mar 22 at 11:11
|
show 2 more comments
Sorry, my fault I forgot to remove theportsdeclaration, it is not in the yaml file.
– Viktor
Mar 22 at 10:27
So on which port iscontent-databaselistening? 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 thenet_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
|
show 2 more comments
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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