I have built a React application that I Dockerized and it works from Docker on my pc. I moved it to a Linux server thru which I connect by a vpn I started the image with: docker run -d -p 3000:3000 client_web:latest
and it is not accessible from my browser and I am connected to the vpn.
Dockerfile:
FROM node:16-slim
ADD . /netlify_react
WORKDIR /netlify_react
RUN npm install
docker-compose.yml:
version: '3.8'
services:
web:
build: .
command: npm start
volumes:
- .:/netlify_react
ports:
- "3000:3000"
Steps I took:
- docker-compose up
- docker save client_web > client_web.tar
- uploaded tar to server
- docker load < client_web.tar
- docker run -d -p 3000:3000 client_web:latest
It starts successfully but I can`t access it from the browser. It gives me - This site can not be reached. I tried with Chrome, Edge, and Chrome incognito.
CodePudding user response:
The default command for the Node image is node
. To make it run npm start, you should add it to the docker run command so it becomes docker run -d -p 3000:3000 client_web:latest npm start
CodePudding user response:
Question
First of all : what do you mean by your server ? a localserver ?
Try
Maybe your container is running behind a firewall or is not listening on 3000 as you expect.
If it is the case, you need to know the hostname where your docker container is really running.
what do you have when doing :
wget http://<your_server> 3000
If you do
firefox localhost:3000
from the command line from your server CLI what do you have?