Skip to content

Commit

Permalink
Merge pull request #4375 from dvdksn/24.0_backport_fix-staticip-example
Browse files Browse the repository at this point in the history
[24.0 Backport] Fix static ip example (docker run)
  • Loading branch information
thaJeztah committed Jun 26, 2023
2 parents bcc889f + 9cd335d commit ddb9220
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/reference/commandline/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
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
$ 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.
Expand Down Expand Up @@ -972,4 +974,4 @@ The `docker run` command is equivalent to the following API calls:
- 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>`.
- `/containers/create` again after pulling the image.
- `/containers/(id)/start` to start the container.
- `/containers/(id)/attach` to attach to the container when starting with the `-it` flags for interactive containers.
- `/containers/(id)/attach` to attach to the container when starting with the `-it` flags for interactive containers.

0 comments on commit ddb9220

Please sign in to comment.