Ranjit Mattamal
Ranjit Mattamal

Reputation: 15

Not able to access the container over localhost

Docker beginner here.

I created a simple asp.net web application , which on run shows me the default page of application.

Using the docker build command, I create a image out of it and further using the docker run command docker run -d --name {containername} -p 81:8080 {imageid}. Now when I try to access the container image over local host on browser i.e. http://localhost:81/, I am getting 'The site cannot be reached' error. I expected the same default page of application to open over the exposed port 81.

My docker client is windows/amd and docker server is linux/amd. The docker version I am using is 19.03.08

Using docker inspect I could see

"PortBindings": {
                "8080/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "81"
                    }
                ]
            },

and "IPAddress": "" in networksettings.

docker ps and docker ps -a

I would appreciate any help or suggestion.

Upvotes: 0

Views: 1955

Answers (1)

user2700022
user2700022

Reputation: 509

From the screen shots attached, it seems your container is killed as soon as its started. You should have a process running in the container to keep it up & running. Only then will you be able to access via the host ip:port In this case http://localhost:81

In your docker ps -a the status is exited. Ideally it should be something like this if your container is up & running.

docker ps

CONTAINER ID        IMAGE                        COMMAND                CREATED              STATUS              PORTS               NAMES
4c01db0b339c        ubuntu:12.04                 bash                   17 seconds ago       Up 16 seconds

Upvotes: 1

Related Questions