I
I
Igor Koch2018-04-25 14:35:23
Docker
Igor Koch, 2018-04-25 14:35:23

How to forward a port from a container to the Internet?

I have a DO server with a standard docker droplet, and a dockerfile:

FROM node:carbon

WORKDIR /var/www/node_cz

RUN npm i --global @adonisjs/cli

EXPOSE 3000

I built it into an image and run:
docker run -v /var/www/node_cz:/var/www/node_cz --name node -p 80:3000 -it whata/node-node /bin/bash

I run adonis.js on port 3000 in it, but I still can't connect to the Internet...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor Koch, 2018-04-25
@amux

Everything turned out to be simple, it was necessary to run the app inside the container at 0.0.0.0:3000 , instead of 127.0.0.1:3000 .

H
Hikmat Abdunabiev, 2018-04-25
@Khikmat

docker run -v /var/www/node_cz:/var/www/node_cz --name node -p 80:3000 -it whata/node-node /bin/bash
With this command you go inside the container. To run it in the background, you need to specify the detached flag , i.e. try like this:
PS: In the dockerfile you install via RUN globally the npm package. I think you also need to add CMD to run the node program.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question