I've got a docker container running an app that needs to proxy requests from itself, to itself to my host machine running an instance of a theme that shares data between the theme and the app. So the app can be used across multiple themes using the relative theme data.
Anyway, I've got an image built using the below Dockerfile
FROM node:12-alpine
EXPOSE 3006
RUN apk update && apk upgrade
RUN apk add \
bash \
git \
openssh
RUN npm install -g -y lerna
Then I create a container using
docker create -it -p 3006:3006 --name=testing -v $(pwd)/build:/build
The container is then started and the app is started using
PORT=3006 react-scripts-ts start screen
Which exposes the app through the container on port 3006. To proxy requests to itself, the package.json
file is set as such
{
"proxy": "http://192.168.1.101:3000"
// Rest of file
}
^ This above setup works but this project is worked on by multiple developers, my concern is that when this is run on a different setup or the host machines local IP isn't 192.168.1.101
then it'll fail.
I've tried setting it to the below
{
"proxy": "http://localhost:3000"
// Rest of file
}
but this fails as presumably this is proxying the requests to the localhost of the container, not the host machine. So essentially my question, in simplistic terms is can I tell a docker container to proxy/reroute a request to localhost (or localhost:3000) to my host machines localhost?