Skip to content

Commit ddb9220

Browse files
authored
Merge pull request #4375 from dvdksn/24.0_backport_fix-staticip-example
[24.0 Backport] Fix static ip example (docker run)
2 parents bcc889f + 9cd335d commit ddb9220

File tree

1 file changed

+5
-3
lines changed
  • docs/reference/commandline

1 file changed

+5
-3
lines changed

docs/reference/commandline/run.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,12 @@ $ docker run -itd --network=my-net busybox
485485
```
486486

487487
You can also choose the IP addresses for the container with `--ip` and `--ip6`
488-
flags when you start the container on a user-defined network.
488+
flags when you start the container on a user-defined network. To assign a
489+
static IP to containers, you must specify subnet block for the network.
489490

490491
```console
491-
$ docker run -itd --network=my-net --ip=10.10.9.75 busybox
492+
$ docker network create --subnet 192.0.2.0/24 my-net
493+
$ docker run -itd --network=my-net --ip=192.0.2.69 busybox
492494
```
493495

494496
If you want to add a running container to a network use the `docker network connect` subcommand.
@@ -972,4 +974,4 @@ The `docker run` command is equivalent to the following API calls:
972974
- If that call returns a 404 (image not found), and depending on the `--pull` option ("always", "missing", "never") the call can trigger a `docker pull <image>`.
973975
- `/containers/create` again after pulling the image.
974976
- `/containers/(id)/start` to start the container.
975-
- `/containers/(id)/attach` to attach to the container when starting with the `-it` flags for interactive containers.
977+
- `/containers/(id)/attach` to attach to the container when starting with the `-it` flags for interactive containers.

0 commit comments

Comments
 (0)