Reputation: 53
I created a docker-container based on nodejs. However, it seems to run fine, but both localhost:8080 and localhost:8443 and localhost can't connect. Also, the connection using curl produces the following message:
$ curl -vvv localhost:8080
* Trying ::1:8080...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.67.0
> Accept: */*
>
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer
$ curl -vvv localhost:8443
* Trying ::1:8443...
* TCP_NODELAY set
* Connected to localhost (::1) port 8443 (#0)
> GET / HTTP/1.1
> Host: localhost:8443
> User-Agent: curl/7.67.0
> Accept: */*
>
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer
This is docker-compose.yml
version: "2"
services:
app:
container_name: app_test
restart: always
build: .
ports:
- "8080:8080"
- "8443:8443"
This is Dockerfile
FROM node:10.12.0
WORKDIR /usr/src/app
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 80 # I try 3000, 8080 instead 80
CMD [ "node", "app.js" ]
And This is result of docker ps
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
735fba0a6ff5 IMAGE_NAME "node app.js" 46 seconds ago Up 45 seconds 0.0.0.0:8080->8080/tcp, 80/tcp, 0.0.0.0:8443->8443/tcp app_test
Neither curl nor browser runs. What should I do?
(I'm awkward because I'm not good at English. Please understand.)
Upvotes: 1
Views: 2825
Reputation: 1094
version: "2"
services:
app:
container_name: app_test
restart: always
build: .
ports:
- "8080:3000"
- "8443:8443"
If you want access your app on localhost:8080, this should work. A node app serves on port 3000 as standard.
So basically:
{port host machine}:{port it actually runs on inside your container}
Upvotes: 4