I am new to docker. When I tried to curl localhost inside container, I got Failed to connect to localhost port 9922: Connection refused.
I saw an answer for mac that is replace localhost with docker.for.mac.localhost which worked for my mac. But what about ubuntu?
Here is the details:
Docker file:
# Use an official Python runtime as a parent image
FROM python:3.7-slim
# Set up working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
# Make port 5000 available to the world outside this container
EXPOSE 5000
#Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "app.py"]
requirements.txt:
numpy
pandas
setuptools
pytest
apscheduler
flask
bokeh
google-api-python-client
google-auth
google-auth-httplib2
oauth2client
tqdm
bs4
tabulate
seaborn
matplotlib
requests
Inside my codes:
url = 'http://docker.for.mac.localhost:9922'
# url = 'http://localhost:9922'
Docker command:
$ docker run --rm -it -p 5000:5000 --name wallet <name-of-image>
Above, if I use url = 'http://docker.for.mac.localhost:9922', it works perfectly. But url = 'http://localhost:9922' won't work. Outside docker container url = 'http://localhost:9922' will work. So here is my question: if i run this docker image on ubuntu what should i use to access localhost? Something like url = 'http://docker.for.ubuntu.localhost:9922'?