Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introduction to Docker!
You have completed Introduction to Docker!
Preview
Before you can make a network connection to a service running on a container, you need to expose the port the service is running on. The EXPOSE instruction allows you to do that.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
The Dockerfile for our web app
ends with the EXPOSE instruction.
0:00
As we discussed in one of
our first demos of Docker,
0:05
before you can make a network connection
to a service running on a container,
0:08
you need to expose the port
the service is running on.
0:11
The EXPOSE instruction
allows you to do that.
0:14
When running the container
with docker run,
0:18
we use the -p option to publish the
exposed port to a port on the Docker host.
0:21
So to publish the exposed port
8080 as port 8080 on our host,
0:27
we run docker run -p
8080:8080 sample-web-app.
0:33
Once we do that, apps will be able
to connect to the exposed port
0:42
via the port we published
it to on the Docker host.
0:46
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up