| 1 |
## Output |
| 2 |
|
| 3 |
```text |
| 4 |
EXPOSE instruction should not define an IP address or host-port mapping, found '127.0.0.1:80:80' |
| 5 |
``` |
| 6 |
|
| 7 |
## Description |
| 8 |
|
| 9 |
The [`EXPOSE`](https://docs.docker.com/reference/dockerfile/#expose) instruction |
| 10 |
in a Dockerfile is used to indicate which ports the container listens on at |
| 11 |
runtime. It should not include an IP address or host-port mapping, as this is |
| 12 |
not the intended use of the `EXPOSE` instruction. Instead, it should only |
| 13 |
specify the port number and optionally the protocol (TCP or UDP). |
| 14 |
|
| 15 |
> [!IMPORTANT] |
| 16 |
> This will become an error in a future release. |
| 17 |
|
| 18 |
## Examples |
| 19 |
|
| 20 |
❌ Bad: IP address and host-port mapping used. |
| 21 |
|
| 22 |
```dockerfile |
| 23 |
FROM alpine |
| 24 |
EXPOSE 127.0.0.1:80:80 |
| 25 |
``` |
| 26 |
|
| 27 |
✅ Good: only the port number is specified. |
| 28 |
|
| 29 |
```dockerfile |
| 30 |
FROM alpine |
| 31 |
EXPOSE 80 |
| 32 |
``` |
| 33 |
|
| 34 |
❌ Bad: Host-port mapping used. |
| 35 |
|
| 36 |
```dockerfile |
| 37 |
FROM alpine |
| 38 |
EXPOSE 80:80 |
| 39 |
``` |
| 40 |
|
| 41 |
✅ Good: only the port number is specified. |
| 42 |
|
| 43 |
```dockerfile |
| 44 |
FROM alpine |
| 45 |
EXPOSE 80 |
| 46 |
``` |