last day (15 days later) » 

8:07 AM
1
A: Docker: requests between containers in one network

atlineAlthough your two containers link to the same default bridge, but this doesn't mean they can visit each other. In the past, we suggest to use --link to make container directly talk to each other without the host participate, but now this is deprecated. Instead, you need to use user-defined brid...

 
what request I need to perform than?
 
Use GET http://rebounder-backend-0017a:8099/log in frontend container.
 
I used this commands: docker network create rebounder-net, docker run --network rebounder-net -p 8099:8099 --name rebounder-back-0021-h2 xpendence/rebounder-chain-backend:0.0.21-H2, docker run --network rebounder-net -p 3000:3000 xpendence/api-checker:0.0.1, than I send request: http://rebounder-back-0021-h2:8099/log, but answer is GET http://rebounder-back-0021-h2:8099/log net::ERR_NAME_NOT_RESOLVED
 
You run the GET in host machine or another container?
 
I send GET request from another container
 
8:07 AM
What's the output of docker network inspect rebounder-net | grep -A20 Containers
 
"Containers": {}, "Options": {}, "Labels": {} }
 
This is really strange, your containers not in the network...
 
stop, I already stopped containers
2 mins
I'll run them & check once more
 
ok, and docker inspect rebounder-back-0021-h2 | grep -A10 Networks to see what's the network your container really use.
 
8:22 AM
"Containers": {
"5a526cd11f014bb970a0a6965ced9702166498635c1b236bf04af6e668b4d1a7": {
"Name": "condescending_khorana",
"EndpointID": "1fba0069b1bf2af6a2333e4868ce30c9e639270ea69182a2381e4a83e1648f56",
"MacAddress": "02:42:ac:17:00:03",
"IPv4Address": "172.23.0.3/16",
"IPv6Address": ""
},
"d326d85b3c038ddbe7563e64c7befb239ca23356aa2c0adf093cf1128e8da00e": {
"Name": "rebounder-back-0021-h2",
"EndpointID": "42247bb920dbd1682b0ee7de404f7a71158e7b39280f7938e13a29af9843c719",
"MacAddress": "02:42:ac:17:00:02",
"Networks": {
"rebounder-net": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"d326d85b3c03"
],
"NetworkID": "1985c91d19051dd2d785db8f8398aca96565b28783507b59926eca5d8693181d",
"EndpointID": "42247bb920dbd1682b0ee7de404f7a71158e7b39280f7938e13a29af9843c719",
"Gateway": "172.23.0.1",
"IPAddress": "172.23.0.2",
 
So, in container condescending_khorana, you can ping 172.23.0.2 ok, but ping rebounder-back-0021-h2 failure?
 
1 min, I'll try
ping rebounder-back-0021-h2
ok
 
So, GET still not work?
 
8:38 AM
How you try this?
/usr/app/front # wget http://rebounder-back-0021-h2:8099/log
Connecting to rebounder-back-0021-h2:8099 (172.18.0.2:8099)
log 100% |*************
wget http://rebounder-back-0021-h2:8099/log
With wget http://rebounder-back-0021-h2:8099/log , it's ok on myside
 
/usr/app/front # wget http://rebounder-back-0021-h2:8099/log
Connecting to rebounder-back-0021-h2:8099 (172.23.0.2:8099)
log 100% |************
 
So, this means your api ready.
Then, how you try this in the past, and get ERR_NAME_NOT_RESOLVED
You can cat log to see it
/usr/app/front # cat log
{"id":1,"created":"2019-05-17 08:37:35.271"}
 
/usr/app/front # cat log
{"id":3,"created":"2019-05-17 08:38:58.238"}/usr/app/front #
 
Yes, as I said, this is the result of your api, is it?
 
8:41 AM
So, ERR_NAME_NOT_RESOLVED?
How you get it?
 
I wrote app which send GET-request which I write
I run it as frontend container
& send requests to backend container
 
Then, the situation is different.
request.js in run in user brower side
And you use ajax to call this api
In fact, it's user to call this api,
Not the container
So you certainly can not get the result
As only the containers in the user defined network can visit eachother
You still need to use host's ip address of docker host
Maybe I miss something, your server side is nodejs?
 
Could tell me the workflow of the send?
It will first send this url to java servlet?
 
8:56 AM
After user click send,
the url will send to java servlet?
 
yes, it's only request to java
requests by machine IP not responds
 
But, the error is in app.js, request.js,
You definely have some request to the url in javascript
How this could be?
As you said the url call happen on java side
You should as you said send the url as a string to java side, which in container, and let web backend to handle the request to this url.
 
no, front on js sending request to back on java
 
No, your understanding is wrong
Although the javascript is in your front container
But, it will render by brower finally
So, it in fact run in user's brower, not in container, not in web backend
 
okay
I understand now
 
9:03 AM
So, we can close the topic?
 
1 min
okay, that was great experience, thanks
 
Welcome, don't forget to accept it, have a good day!
 

last day (15 days later) »