Connection refused on docker container

后端 未结 6 918
面向向阳花
面向向阳花 2020-12-13 05:47

I\'m new to Docker and trying to make a demo Rails app. I made a dockerfile that looks like this:

FROM ruby:2.2
MAINTAINER marko@codeship.com

# Install apt         


        
6条回答
  •  不知归路
    2020-12-13 06:12

    Command EXPOSE in your Dockerfile lets you bind container's port to some port on the host machine but it doesn't do anything else. When running container, to bind ports specify -p option.

    So let's say you expose port 5000. After building the image when you run the container, run docker run -p 5000:5000 name. This binds container's port 5000 to your laptop/computers port 5000 and that portforwarding lets container to receive outside requests.

    This should do it.

提交回复
热议问题