PurpleSmurph
PurpleSmurph

Reputation: 2107

How can I get my remote dockerised website to be accessible

I am trying to display my website from within a Docker container on a remote server but can't access it through my browser.

"This site can't be reached. {thisIp} refused to connect".

When looking on the server I can see the process is active website logging (every x seconds it tells me it's alive for the purpose of testing).

The server has port 5001 exposed and if I run the site using dotnet run I can access it and everything is fine.

I have come stuck with how to marry up the containerised website and the exposed port on the server, in my docker file I have EXPOSE 80.

When launching it tells me it is listening on http://::80

How can I get my containerised website to display through port 5001?

Upvotes: 0

Views: 701

Answers (1)

andrzejwp
andrzejwp

Reputation: 952

It's not enough to EXPOSE the port. You also have to map it to a specific port on your server.

If you're using simple docker shell command then you have to

docker run --publish 5001:80 your_docker_image

read more in docker docs.

If you're using docker-compose - then the syntax is a bit different:

# ... snip ...

ports:
  - 5001:80

# ... snip ...

read more here

Upvotes: 1

Related Questions