Request from Frontend Container to Backend container










0














I have seen several possibilities how to communicate between docker containers. I tried the most of them except proxying which i cant translate to my scenario.



I have a vue-frontend, java-backend- container.
In the frontend i use axios to make http request.



I want to make a http request axios.get(http:localhost:7080/ping), which gives me status 200 but I dont get an response and some CORS problem.(Which is very strange, because the cors header are present if i use postman for the request)



If i use axios.get(http:container_name:7080/ping) I get some other error
net::ERR_NAME_NOT_RESOLVED.



Other solutions (using nginx) using reverse proxy. Do I need something like this or do I have some other misconfiguration?



My docker-compose looks like this:



 services:
backend:
container_name: backend
build: ./backend
volumes:
- xxx
ports:
- 7048:7048
- 7080:7080
- 7009:9009
frontend:
container_name: frontend
build:
context: ../frontend
dockerfile: ./Dockerfile
volumes:
- ../xxx
ports:
- 8080:8080
#- 8001:8001
depends_on:
- backend
environment:
- NODE_ENV=development
# - CHOKIDAR_USEPOLLING=true









share|improve this question





















  • Where is the actual HTTP call happening? Is the frontend container directly calling the backend, or is it serving up a Web application that's making the outbound HTTP call from the user's browser?
    – David Maze
    Nov 11 '18 at 22:10










  • The frontend containers serves a vue.js application which makes the call to the backend
    – greedsin
    Nov 11 '18 at 22:11










  • ...so the URL needs to be a name the browser can resolve, which is probably the host name of the server running the backend container (could be localhost only in a development environment where you know the browser and the Docker setup are running on the same physical host).
    – David Maze
    Nov 11 '18 at 22:15










  • which is contradictory to the already given answer?....
    – greedsin
    Nov 11 '18 at 22:16















0














I have seen several possibilities how to communicate between docker containers. I tried the most of them except proxying which i cant translate to my scenario.



I have a vue-frontend, java-backend- container.
In the frontend i use axios to make http request.



I want to make a http request axios.get(http:localhost:7080/ping), which gives me status 200 but I dont get an response and some CORS problem.(Which is very strange, because the cors header are present if i use postman for the request)



If i use axios.get(http:container_name:7080/ping) I get some other error
net::ERR_NAME_NOT_RESOLVED.



Other solutions (using nginx) using reverse proxy. Do I need something like this or do I have some other misconfiguration?



My docker-compose looks like this:



 services:
backend:
container_name: backend
build: ./backend
volumes:
- xxx
ports:
- 7048:7048
- 7080:7080
- 7009:9009
frontend:
container_name: frontend
build:
context: ../frontend
dockerfile: ./Dockerfile
volumes:
- ../xxx
ports:
- 8080:8080
#- 8001:8001
depends_on:
- backend
environment:
- NODE_ENV=development
# - CHOKIDAR_USEPOLLING=true









share|improve this question





















  • Where is the actual HTTP call happening? Is the frontend container directly calling the backend, or is it serving up a Web application that's making the outbound HTTP call from the user's browser?
    – David Maze
    Nov 11 '18 at 22:10










  • The frontend containers serves a vue.js application which makes the call to the backend
    – greedsin
    Nov 11 '18 at 22:11










  • ...so the URL needs to be a name the browser can resolve, which is probably the host name of the server running the backend container (could be localhost only in a development environment where you know the browser and the Docker setup are running on the same physical host).
    – David Maze
    Nov 11 '18 at 22:15










  • which is contradictory to the already given answer?....
    – greedsin
    Nov 11 '18 at 22:16













0












0








0







I have seen several possibilities how to communicate between docker containers. I tried the most of them except proxying which i cant translate to my scenario.



I have a vue-frontend, java-backend- container.
In the frontend i use axios to make http request.



I want to make a http request axios.get(http:localhost:7080/ping), which gives me status 200 but I dont get an response and some CORS problem.(Which is very strange, because the cors header are present if i use postman for the request)



If i use axios.get(http:container_name:7080/ping) I get some other error
net::ERR_NAME_NOT_RESOLVED.



Other solutions (using nginx) using reverse proxy. Do I need something like this or do I have some other misconfiguration?



My docker-compose looks like this:



 services:
backend:
container_name: backend
build: ./backend
volumes:
- xxx
ports:
- 7048:7048
- 7080:7080
- 7009:9009
frontend:
container_name: frontend
build:
context: ../frontend
dockerfile: ./Dockerfile
volumes:
- ../xxx
ports:
- 8080:8080
#- 8001:8001
depends_on:
- backend
environment:
- NODE_ENV=development
# - CHOKIDAR_USEPOLLING=true









share|improve this question













I have seen several possibilities how to communicate between docker containers. I tried the most of them except proxying which i cant translate to my scenario.



I have a vue-frontend, java-backend- container.
In the frontend i use axios to make http request.



I want to make a http request axios.get(http:localhost:7080/ping), which gives me status 200 but I dont get an response and some CORS problem.(Which is very strange, because the cors header are present if i use postman for the request)



If i use axios.get(http:container_name:7080/ping) I get some other error
net::ERR_NAME_NOT_RESOLVED.



Other solutions (using nginx) using reverse proxy. Do I need something like this or do I have some other misconfiguration?



My docker-compose looks like this:



 services:
backend:
container_name: backend
build: ./backend
volumes:
- xxx
ports:
- 7048:7048
- 7080:7080
- 7009:9009
frontend:
container_name: frontend
build:
context: ../frontend
dockerfile: ./Dockerfile
volumes:
- ../xxx
ports:
- 8080:8080
#- 8001:8001
depends_on:
- backend
environment:
- NODE_ENV=development
# - CHOKIDAR_USEPOLLING=true






docker vuejs2 docker-compose






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 '18 at 22:04









greedsin

329721




329721











  • Where is the actual HTTP call happening? Is the frontend container directly calling the backend, or is it serving up a Web application that's making the outbound HTTP call from the user's browser?
    – David Maze
    Nov 11 '18 at 22:10










  • The frontend containers serves a vue.js application which makes the call to the backend
    – greedsin
    Nov 11 '18 at 22:11










  • ...so the URL needs to be a name the browser can resolve, which is probably the host name of the server running the backend container (could be localhost only in a development environment where you know the browser and the Docker setup are running on the same physical host).
    – David Maze
    Nov 11 '18 at 22:15










  • which is contradictory to the already given answer?....
    – greedsin
    Nov 11 '18 at 22:16
















  • Where is the actual HTTP call happening? Is the frontend container directly calling the backend, or is it serving up a Web application that's making the outbound HTTP call from the user's browser?
    – David Maze
    Nov 11 '18 at 22:10










  • The frontend containers serves a vue.js application which makes the call to the backend
    – greedsin
    Nov 11 '18 at 22:11










  • ...so the URL needs to be a name the browser can resolve, which is probably the host name of the server running the backend container (could be localhost only in a development environment where you know the browser and the Docker setup are running on the same physical host).
    – David Maze
    Nov 11 '18 at 22:15










  • which is contradictory to the already given answer?....
    – greedsin
    Nov 11 '18 at 22:16















Where is the actual HTTP call happening? Is the frontend container directly calling the backend, or is it serving up a Web application that's making the outbound HTTP call from the user's browser?
– David Maze
Nov 11 '18 at 22:10




Where is the actual HTTP call happening? Is the frontend container directly calling the backend, or is it serving up a Web application that's making the outbound HTTP call from the user's browser?
– David Maze
Nov 11 '18 at 22:10












The frontend containers serves a vue.js application which makes the call to the backend
– greedsin
Nov 11 '18 at 22:11




The frontend containers serves a vue.js application which makes the call to the backend
– greedsin
Nov 11 '18 at 22:11












...so the URL needs to be a name the browser can resolve, which is probably the host name of the server running the backend container (could be localhost only in a development environment where you know the browser and the Docker setup are running on the same physical host).
– David Maze
Nov 11 '18 at 22:15




...so the URL needs to be a name the browser can resolve, which is probably the host name of the server running the backend container (could be localhost only in a development environment where you know the browser and the Docker setup are running on the same physical host).
– David Maze
Nov 11 '18 at 22:15












which is contradictory to the already given answer?....
– greedsin
Nov 11 '18 at 22:16




which is contradictory to the already given answer?....
– greedsin
Nov 11 '18 at 22:16












0






active

oldest

votes











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%2f53253715%2frequest-from-frontend-container-to-backend-container%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f53253715%2frequest-from-frontend-container-to-backend-container%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

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus