I’ve built my first Docker container but when I run the container either it won’t load or I’m looking in the wrong place. My command line is returning a huge long number without any errors, so I’m assuming I should be able to access the container. However, when I go to http://0.0.0.0:5001/
or http://localhost:5001/
I’m given the error message The site can't be reached
I’m using WSL2 (Ubuntu 20.04) to build the Dash application in Python. I have a Windows 10 machine and I’ve ensured that Docker is set to be compatible with WSL2 and Ubuntu. Below is a copy of my Dockerfile, the code I’ve used to build the container and the code I’ve used to run the container.
When I run the container, it seems to open Python but I’m not too sure what I should be typing into the terminal.
My Docker logs are showing:
Python 3.8.12 (default, Oct 13 2021, 09:15:35)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> docker run
File "<stdin>", line 1
docker run
^
SyntaxError: invalid syntax
>>> run index.py
File "<stdin>", line 1
run index.py
^
SyntaxError: invalid syntax
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()
Please can someone explain how I’m supposed to access the Docker container that I’ve built and run? I’m expecting to see the application that I’ve created when I go to either http://0.0.0.0:5001/
or http://localhost:5001/
.
Docker build command: docker build . -t october-2021-challenge-3
Docker run command: docker container run -p 5001:5001 -it --name -stwd-oct-3 october-2021-challenge-3
Dockerfile:
ARG APP_IMAGE=python:3.8
FROM $APP_IMAGE AS base
FROM base as builder
RUN mkdir /install
WORKDIR /install
COPY requirements.txt /requirements.txt
RUN pip install --upgrade pip
RUN python3 -m pip install -r /requirements.txt
FROM base
ENV FLASK_APP index
WORKDIR /project
COPY --from=builder /install /usr/local
ADD . /project
ENTRYPOINT ["python3"]
My requirements file:
Brotli==1.0.9
click==8.0.2
dash==2.0.0
dash-bootstrap-components==0.13.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0
Flask==2.0.0
Flask-Compress==1.10.1
itsdangerous==2.0.1
Jinja2==3.0.2
MarkupSafe==2.0.1
numpy==1.21.2
pandas==1.3.3
plotly==5.3.1
python-dateutil==2.8.2
pytz==2021.3
six==1.16.0
tenacity==8.0.1
Werkzeug==2.0.2