Reputation: 783
I am trying to develop a simple react app and I am trying to use docker for running a development server, but it is not connecting up in the browser
Here is the Dockerfile.dev
FROM node:alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "start"]
EXPOSE 3000
Here are the two commands to create and run the container
docker build -f Dockerfile.dev .
docker run -p 3000:3000 <image_id>
It's starting a development server as the normal npm start does but it is not running in the browser at localhost:3000
Upvotes: 0
Views: 446
Reputation: 59896
You container will exist if you did not mention -it
or -dit
(if its not typo in question). The reason being stopped immediately because bash can't find any pseudo terminal to be allocated. You have to specify -it
or -dit
so that bash or sh can be allocated to a pseudo-terminal.
docker run --name test -p 3000:3000 <image_id>
If you run docker ps | grep test
you will see in the output
"/bin/bash" {some} seconds ago Exited (0) {some} seconds ago
Now try to run with
docker run --name test -dit -p 3000:3000 <image_id>
or
docker run --name test -it -p 3000:3000 <image_id>
Good to go localhost:3000
Updated:
For window, docker toolbox follows these steps.
Click the appropriate machine (probably the one labeled "default") Settings
Run the command:
docker run -dit -p 3000:3000 ${image_id}
Upvotes: 1