dennismuys dennismuys - 1 year ago 81
Node.js Question

portforwarding a node/postgres application in docker

I'm getting started with docker and I am trying to run a node/postgres application.
When I run the app using docker-compose up I get the following output:

Starting nodedocker_db_1
Starting nodedocker_myapp_1
Attaching to nodedocker_db_1, nodedocker_myapp_1
db_1 | LOG: database system was shut down at 2016-08-03 08:33:02 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: autovacuum launcher started
db_1 | LOG: database system is ready to accept connections
myapp_1 | npm info it worked if it ends with ok
myapp_1 | npm info using npm@2.15.8
myapp_1 | npm info using node@v4.4.7
myapp_1 | npm info prestart NEXTofferte@0.0.1
myapp_1 | npm info start NEXTofferte@0.0.1
myapp_1 |
myapp_1 | > NEXTofferte@0.0.1 start /usr/src/app
myapp_1 | > node server.js
myapp_1 |
myapp_1 | Server running at http://localhost:3000/

Okay great, it is working, but I cant reach localhost 3000 from my system.
So I try forwarding it using this:

docker build -t devoon/offerteportaal .
docker-compose run -p 49160:3000 -d devoon/offerteportaal

The build finishes without errors but the run command gives the error no such service: devoon/offerteportaal

I hope someone here can point me in the right direction.

I went with the second option in the answer and edited my yml file.
I will include it in the question for clarity:


image: postgres
build: .
- "49160:3000"
- db
- PGDB=offerteportaal
- POSTGRES_USER=postgres
- DATABASE_URL=postgres://postgres:postgres@db:5432/offerteportaal

Answer Source

You either want docker run -p 49160:3000 -d devoon/offerteportaal or modify your docker-compose.yml file:

  image: ...

  build: .
    - "49160:3000"

and than docker-compose up -d