Hi I'm very new to Docker, I'm trying to get familiar with Docker by following the tutorial on official site. Now I get stuck at part 2 of the tutorial (where you can check up the link here => https://docs.docker.com/get-started/part2/#run-the-app)
I have sample application code, Dockerfile, and requirements.txt exactly same as the offical tutorial
$ ls
app.py Dockerfile requriements.txt
My Dockerfile looks like this
FROM python:2.7-slim
WORKDIR /app
ADD . /app
RUN pip install -r requriements.txt
EXPOSE 80
ENV NAME World
CMD ["python", "app.py"]
All 3 files have file content/code exactly same as the tutorial also. I was able to build image registry with this command
$ docker build -t friendlyhello .
Everything looks great. Now I had sample project image registry.
$ docker images
REPOSITORY TAG IMAGE ID CREATED
friendlyhello latest 82b8a0b52e91 39 minutes ago
python 2.7-slim 1c7128a655f6 5 days ago
hello-world latest 48b5124b2768 4 months ago
I then ran the app according to the official tutorial with this command
$ docker run -d -p 4000:80 friendlyhello
c1893f7eea9f1b708f639653b8eba20733d8a45d3812b442bc295b43c6c7dd5c
Edit: This is my container after ran above command
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS
c1893f7eea9f friendlyhello "python app.py" 15 minutes ago Up 16 minutes
And the official tutorial guides readers to have a look at http://localhost:4000
as they have already mapped machine port 4000
to container port 80
Unfortunately, I couldn't get any response from that URL.
$ curl http://localhost:4000
curl: (7) Failed to connect to localhost port 4000: Connection refused
I'm totally newbie and I have no idea what to do....How can I get it to work ? Thanks in advance for any response.
Edit: I did as @johnharris85 suggested. Below is the output
$ curl http://$(echo docker-machine ip default):4000
curl: (6) Couldn't resolve host 'docker-machine'
curl: (6) Couldn't resolve host 'ip'
curl: (6) Couldn't resolve host 'default'
It seems like it doesn't work either.
Edit: @johnharris85 corrected his suggestion and @user8023051 clarify how this command come from and what is going on under the hood. It is working now :) Thanks
$ curl http://$(docker-machine ip default):4000
<h3>Hello World!</h3><b>Hostname:</b> c1893f7eea9f<br/><b>Visits:</b> <i>cannot connect to Redis, counter disabled</i>