Reputation: 175
I have a react app running inside a container. I need to request an API(not mine) and it only accepts public IP addresses. Can the container use the public address of my machine?
version: '3'
services:
client:
container_name: client
build:
context: ./client
dockerfile: Dockerfile
volumes:
- './client:/usr/src/app'
- '/usr/src/app/node_modules'
ports:
- '3000:3000'
environment:
- NODE_ENV=development
- NODE_PATH=src
Upvotes: 2
Views: 2612
Reputation: 2174
As to your question: Can the container use the public address of my machine?
Yes, it even does so if you do not specify --net host
. You can check that easily using this image (or any other image that contains curl
):
First, run this on your host:
curl -s ipinfo.io/ip
This will show your current public IP address.
Then, run the container:
docker run --rm appropriate/curl -s ipinfo.io/ip
It should result in the same IP address.
I don't know anything about React, though, so there might be other stuff going on in your case, but basically this should not be a Docker problem.
Upvotes: 1