Docker run error: website can't be open, server error

Hello, I am pretty new on docker, I try now with command on terminal my web-app …but it gives error , it says that Safari can’t be open the website, server is overloaded, try again later…
but it give later the same error too.

my command is:

docker run -p 5000:5000 --volume=/User/dogacetinkaya/Desktop/pexonhwdockerfilekopie:/app pexonhwdoga

if u can help me to find my mistake, I ll be very thankful…

Doga C.


What is “pexonhwdoga” ?

it needs to be an image name

I did it with
$ docker build -t pexonhwdoga .
as an image name…

what should I take ?

fair enough.

Find the container id or name by running: docker ps -a, and try and see if it posted any logs before it quit with: docker logs ID/NAME

What we really need to know is what is inside your Dockerfile to see how you started your web site.

What network adapter is your site listening on? If it’s that’s your problem. The site is listening on localhost which is why it can’t be seen outside of the container. You need to bind your web site to so that it’s listening on all network adapters. Then it can be reached from outside of the container.

1 Like

hi, first of all , thx for the answer.
my docker file is:

Dockerfile, Image, Container

FROM python:3.8-slim

#convention to create an environment variable

#it will set the value this environment variable to 1

RUN pip install --upgrade pip

#copy everything to this expected /code going to be created within oour container

# copy the requierements.txt and installing each of the dependency on this container

#it will be copied in /code/

COPY ./requirements.txt /app/requirements.txt


#working directory


#we want to make sure that each of our dependencies are going to be installed in our container

RUN pip install -r requirements.txt

#copy the entire project to the directory that we have created

COPY . /app

#entrypoint of our container

CMD ["python", ""]

an my docker-compose.yml :

version: '3'
    build: .
      - "80:80"
    - .:/app:/Desktop/pexonhwdockerfilekopie/
    image: redis

and main :

if __name__ == '__main__':'', port=80)

and now if I run it with “docker compose up”, then it gives two url which are and
127… is running but 172… takes a little bit and says that website can’t be open…

and if I run it over with “python3”, then it gives:

  • Running on
  • Running on (Press CTRL+C to quit)
    so both of them is running correctly.

finally i didn’t understand where am I doing mistake

i am very thankful if u can help me…

When you run locally, is the IP address and port on your local computer. I’m guessing you are using Docker Desktop which is creating a Linux VM in the background and the is the IP address of that Linux VM which is why you can’t reach it from your local computer.


thx for your answer…
yes I have a docker desktop…
now I understand why it does not work.

thank u sooo much…:slight_smile:

@dogacet I edited your post. Please, follow tips in the following post next time to help us by making your post more readable and get an answer more quickly.

Luckily for you, @rofrano gave you great advice even without formatting. I just want to add clarify some possible misunderstaning.

Actually both and is an IP address inside the container. works, because of port forwarding. In other words: publishing port 80. Then host machine has its own loopback IP and port 80 is forwarded from that IP into the container in the virtual machine. One of the jobs of Docker Desktop is to forward ports from the host to the virtual machine, so Docker inside that VM can forward the port from the VM into the container. The IP address does not exist on the host machine, because that belongs to a local, private interface inside the VM. That is why it doesn’t work. Applications running inside the container do not know anything about the IP addresses of the host machine, at least not in case of Docker Desktop, so you can’t rely on the information shown in the containers’ console.

You’re welcome. While it’s nice that Docker Desktop gives you the illusion that Docker is running natively on your Mac or Windows computer, it’s important to understand that it is not and there is a hidden Linux VM that’s actually running Docker. Glad I could help.

hi, i understood now.

this is my project on GitHub , can u maybe run it at once. i want to know if it is running on any other computer?

thx very much…

I did and It doesn’t work on another computer for several reasons. First you have hard coded the path: /Desktop/pexonhwdockerfilekopie/ into your docker-compose.yml file. That path does not exist on my computer. I’m not sure why you felt you needed it. The volume .:/app already shares your current folder inside the container as /app. Just remove it.

When I removed that, the next error I get is:

jinja2.exceptions.TemplateNotFound: index.html

Because Flask templates should be in a ./templates folder by default. Your repo has no folders. Everything is in the root including compiled python .pyc files that should not be checked into GitHub. You should always create a .gitignore file for the language you are using so that these compiled files are not checked in. GitHub will prompt you to create one when you create the repo. You should always allow it to do this.

However, from your compiled Python files I can see that you were using Python 3.10 on your computer but your Dockerfile is using Python 3.8. You always want to use the same version of Python in all of your environments for “Dev/Prod parity” so I would update your Dockerfile to use python:3.10-slim

Once I created a ./templates folder and moved the *.html files into it, the application worked! :smiley:

Finally, I’m not sure why your docker-compose.yml file is running redis since you are not using it. I realize that you are just learning Docker. I would replace redis with postgres since you are using SQLAlchemy and then configure your app to use PostgreSQL instead of SQLite. That would be a good next step for you.

This is a good first attempt at learning Docker. You are well on your way to understanding it.

thx thx thx very much, u gave me so helpful infos, I will immediately make Changes.
u are right, i learn very first time docker and co.
and that is my first project with python. but I have fun doing it. and I m so thankful of u…

You’re welcome. As long as you’re having fun… that’s what really counts. :smiley: