Skip to content

Commit 605942c

Browse files
authored
Merge pull request #4374 from dvdksn/docs/run-staticip-subnet
docs: fix static ip example, network needs a subnet
2 parents adc9d1f + 5936fd2 commit 605942c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • docs/reference/commandline

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)