Sunday, 2 April 2017

Can't connect to Express server inside Docker container created with docker-compose

I have a stack of a MySQL database, a redis cache and a web server written in Express.

The entire stack is working and connecting to each other correctly. This is my final Node log:

users-service       | debug: [SERVER] Initializing routes
users-service       | debug: starting Route: auth
users-service       | debug: starting Route: flows
users-service       | debug: starting Route: users
users-service       | debug: [SERVER] Listening on port 3001

docker ps tells me that the container is mapping the ports correctly:

CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                    NAMES
f6a99ecdd218        users-service         "nodemon start"          52 minutes ago      Up 2 minutes        0.0.0.0:3001->3001/tcp   users-service
38966d30ec0a        redis                 "docker-entrypoint..."   59 minutes ago      Up 2 minutes        0.0.0.0:6379->6379/tcp   users-service-redis
fb79ec8fb50c        users-service-mysql   "docker-entrypoint..."   About an hour ago   Up 2 minutes        0.0.0.0:3306->3306/tcp   users-service-mysql

Inside the web container, the Node process (nodemon, in this case) is running:

PID   USER     TIME   COMMAND
  1   root     0:00   node /usr/local/bin/nodemon start
 21   root     0:00   sh -c node start start.js
 22   root     0:00   node start start.js
 32   root     0:00   sh
 37   root     0:00   ps

However, when I try to access port 3001 with curl or postman, they simply wait for response till timeout.

An interesting thing is that this don't work only on my machine. In my teammate's machine it goes up and he can connect to port 3001 with no problems.

So I suspect it is a problem with my machine, but I'm not sure what.

I'll appreciate any help. Thank you in advance.



via Andrey Luiz

No comments:

Post a Comment