Docker is an open-source project that makes it easier to create, deploy and run applications. It provides a lightweight environment to run your applications.
It is a tool that makes an isolated environment inside your computer. Think of Docker as your private room in your house. Living with your family, you have to share a TV, table, chair and so on. Once you get into your room, all are yours. You don’t have to share them, and feel private, though your family may listen to your voice and tell you to be calm. Docker is like your room. Docker can be private from the host computer, though in some parts it is monitored and controlled by the host.
Let’s Come to Our Problem statement: We Want to Create a Docker Container with Static IP.
Let’s Say We have configured our Server and Connected with CICD tools which Update the Application and Relaunch our Complete Docker Environment But as the New Environment is Created Which lead to change the IP definitely But Our Use Case is that We Don’t Want to Change Because Might be that some other application depends on it and if the IP changed then that application Stop Working.
Solution:
Step 1: Configure the Docker in the Server
Step 2: Create a Network with Subnet (CIDR).
Step 3: Deploy the Container this Network with your Custom Static IP
- Specify:
- Network Name (Which You at the time of Creation Of Network)
- Specify the IP (Which is Under that Network)
Output: