/plushcap/analysis/spacelift/docker-expose-port

How to Expose a Docker Port – Tutorial & Examples

What's this blog post about?

Docker's networking model isolates containers from the host system, with each container having its own port range. To access a container over your host's network, you need to expose and publish the target container port yourself. Exposing a port in Docker means advertising it as actively used by the containerized workload, while publishing or binding a port allocates a host port to a container port, allowing communication with the container from your host's networking interface. The EXPOSE instruction within a Dockerfile and the --expose flag when starting a container are two ways to expose a port in Docker. To publish a port, use the -p flag for docker run.

Company
Spacelift

Date published
Jan. 19, 2024

Author(s)
James Walker

Word count
1695

Hacker News points
None found.

Language
English


By Matt Makai. 2021-2024.