Merge pull request #4375 from dvdksn/24.0_backport_fix-staticip-example

[24.0 Backport] Fix static ip example (docker run)
This commit is contained in:
Sebastiaan van Stijn 2023-06-26 17:22:57 +02:00 committed by GitHub
commit ddb9220abf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -485,10 +485,12 @@ $ docker run -itd --network=my-net busybox
``` ```
You can also choose the IP addresses for the container with `--ip` and `--ip6` You can also choose the IP addresses for the container with `--ip` and `--ip6`
flags when you start the container on a user-defined network. flags when you start the container on a user-defined network. To assign a
static IP to containers, you must specify subnet block for the network.
```console ```console
$ docker run -itd --network=my-net --ip=10.10.9.75 busybox $ docker network create --subnet 192.0.2.0/24 my-net
$ docker run -itd --network=my-net --ip=192.0.2.69 busybox
``` ```
If you want to add a running container to a network use the `docker network connect` subcommand. If you want to add a running container to a network use the `docker network connect` subcommand.