Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Introduction to Docker Building Images Using Dockerfiles The ENTRYPOINT and CMD Instructions

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Docker course files?

Hi,

Are the course files available for download somewhere?

Also, I am unable to connect to localhost:8080. What could be the issue?

Here is my Dockerfile:

# Base image
FROM ubuntu:latest

# Commands to run to install dependencies
RUN apt-get update -y
RUN apt-get install -y python3

# When you pass commands to the container, what should interpret them
ENTRYPOINT ["python3"]

# Command to run when the container starts
CMD ["app.py"]

# Working directory
WORKDIR /app

# Copy apps from the local folder to the Docker container
COPY app.py app.py
COPY alternate.py alternate.py

# Make port available
EXPOSE 8080

Thanks!

3 Answers

Jared Smith
STAFF
Jared Smith
Treehouse Guest Teacher

Hi Juliette,

Make sure when you run the Docker container, that you pass the -p option with 8080:8080 as the argument, or else Docker will not bind the exposed container port to your computer's interface.

See the docs here: https://docs.docker.com/engine/reference/run/#expose-incoming-ports

Best, Jared

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Hi Jared,

Thanks for getting back to me!

These are the commands that I am running from my home directory:

docker build -t sample-web-app:1.0 .

docker run -p 8080:8080 sample-web-app

Localhost is (still) refusing to connect and I'm not sure what to do to get it to start.

I had no problem starting a mongod instance (and mongo) from within Docker, but this one is eluding me.

Thanks in advance for any further clues:-)

Yash Gopal
Yash Gopal
4,638 Points

Make sure no other containers are using the same ports? Maybe try stopping all containers and re-running those commands from within the directory that you have the dockerfile / project in.

localhost doesn't work if you are using docker-toolbox on Windows because it has to use Virtualbox. You'll need to use the IP address of the virtual machine docker creates, which is 192.168.99.1. So you would connect using http://192.168.99.1:8080.