1. [Home](<https://delaparra-services.nl/>) 
1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) 
1. [port mapping](<https://delaparra-services.nl/knowledge-hub/port-mapping>)

  

Category: Docker 

# port mapping

  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    

## What is port mapping?

 

port mapping: Publishing a container port to a host port so external clients can reach it. The -p HOST:CONTAINER flag. Port mapping publishes a port inside a container on a port of the host machine. ` docker run -p 8080:80 nginx ` makes the web server inside the container, listening on port 80, reachable at port 8080 on your computer.

 

Definition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)

 

## Frequently asked questions about port mapping

  

### How is port mapping used in practice?

 

The format is always host port first, then container port. You can also bind to a specific address, such as ` -p 127.0.0.1:8080:80 `, so the port is only reachable from the machine itself.

    

### What should you keep in mind with port mapping?

 

That last form matters on servers. By default, Docker publishes ports on all network interfaces and adds firewall rules that can bypass tools like UFW. A database published with ` -p 3306:3306 ` on a public server may be reachable from the whole internet. Publish only what needs to be public, and bind internal services to ` 127.0.0.1 ` or leave them unpublished.

    

### What does an example of port mapping look like?

 

```
docker run -p 8080:80 nginx
```

 

## At a glance

   CategoryDocker Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026

 

## More Docker terms

 

- [multi-stage build](<https://delaparra-services.nl/knowledge-hub/multi-stage-build>) 
- [networks (compose)](<https://delaparra-services.nl/knowledge-hub/networks-compose>) 
- [none](<https://delaparra-services.nl/knowledge-hub/none>) 
- [ports](<https://delaparra-services.nl/knowledge-hub/ports>) 
- [pull](<https://delaparra-services.nl/knowledge-hub/pull>) 
- [push](<https://delaparra-services.nl/knowledge-hub/push>)

 

[All terms starting with P](<https://delaparra-services.nl/knowledge-hub#letter-p>)

 

## Skills

 

- ### Docker Project Foundations

 

Use this skill when setting up, initializing, or Dockerizing a project, even if the user doesn't explicitly mention Docker but describes a need for containerized local development, adding a database or cache dependency, or running services without host-level installs. Covers Dockerfile, compose.yaml, and .dockerignore creation with Docker best practices.

 [View skill](<https://delaparra-services.nl/skills/docker-project-foundations>) [Download zip](<https://delaparra-services.nl/skills/docker-project-foundations/download>) 
- ### Docker Compose Patterns

 

Use this skill when creating, modifying, or debugging Docker Compose configurations, even if the user just says they need to wire services together, add a database to their stack, or set up a local development environment with multiple containers. Covers service definitions, health checks, dependency ordering, volumes, networks, environment variables, and development overrides.

 [View skill](<https://delaparra-services.nl/skills/docker-compose-patterns>) [Download zip](<https://delaparra-services.nl/skills/docker-compose-patterns/download>) 
- ### Docker Build Strategies

 

Use this skill when writing, reviewing, or optimizing Dockerfiles, even if the user just says their image is too large, their build is slow, or they need to harden a container for production. Covers multi-stage builds, layer caching, .dockerignore, non-root users, and image size optimization.

 [View skill](<https://delaparra-services.nl/skills/docker-build-strategies>) [Download zip](<https://delaparra-services.nl/skills/docker-build-strategies/download>)

 [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/port-mapping/skills.zip>)

 

## Manuals

 

- [Docker for your Laravel app](<https://delaparra-services.nl/manuals/docker-voor-je-laravel-app>) 
- [Deploying a Laravel app](<https://delaparra-services.nl/manuals/je-laravel-app-online-zetten>)

 

## Related services

 

- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)

Perhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet.

 

## Need any help?

 

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.

  [Get in touch](<https://delaparra-services.nl/availability>)

[HTML version](https://delaparra-services.nl/knowledge-hub/port-mapping)
