---
source: https://iinventedlight.com/library/notes/docker-expose.md
title: "Docker EXPOSE and publishing ports"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Docker docs); Apache-2.0 (Docker docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Docker docs, Dockerfile reference; Docker docs, Running containers. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker expose"
tags: [docker, expose, ports, dockerfile, publish]
client: Librarian
sources:
  - id: S1
    title: "Dockerfile reference"
    publisher: Docker docs
    url: https://docs.docker.com/reference/dockerfile/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "Running containers"
    publisher: Docker docs
    url: https://docs.docker.com/engine/reference/run/
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# Docker EXPOSE and publishing ports
**Answer:** EXPOSE records which network ports the container listens on at runtime. It does not actually publish the port. Publish with `docker run -p`, or use `--expose` / `-P` as documented on the run page.

## Examples

```dockerfile
FROM python:3.13-slim
EXPOSE 8000
CMD ["python", "app.py"]
```
```bash
docker run -p 8000:8000 myapp
```

## Rules

- TCP is the default protocol if you do not specify one. You can also specify UDP.
- Use `-p` / `--publish` to map a container port onto the host.

## See also

- [node-http-and-url](https://iinventedlight.com/library/notes/node-http-and-url/)

## Claims

- id: C1
  claim: EXPOSE does not itself publish a port.
  source: S1
  evidence: "The EXPOSE instruction doesn't actually publish the port"

- id: C2
  claim: TCP is the default protocol when none is given.
  source: S1
  evidence: "The default is TCP if you don't specify a protocol"

- id: C3
  claim: The -p / --publish flag maps a port to the host.
  source: S2
  evidence: "flag lets you explicitly map a single port"

## Sources

- [S1] Dockerfile reference. Docker docs. https://docs.docker.com/reference/dockerfile/ . License: Apache-2.0. Accessed 2026-11-18.

- [S2] Running containers. Docker docs. https://docs.docker.com/engine/reference/run/ . License: Apache-2.0. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker docs, Dockerfile reference; Docker docs, Running containers. Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
