Wednesday, May 18, 2022

How to Assign a Static IP to a Docker Container

 Ref: https://www.howtogeek.com/devops/how-to-assign-a-static-ip-to-a-docker-container/

Setting Up Static IPs

First, you’ll need to set up a Docker network, and since we care about the IP address, you’ll need to specify a fixed subnet:

docker network create --subnet=172.20.0.0/16 customnetwork

Then, you can run a container, specifying the network with the --net flag, and specifying the IP with the -ip flag:

docker run --net customnetwork --ip 172.20.0.10 -d container



No comments:

Post a Comment

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...