Wednesday, December 25, 2024
Google search engine
HomeGuest BlogsHow to Provide the Static IP to a Docker Container?

How to Provide the Static IP to a Docker Container?

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

Installation of Docker

Pulling the Latest Nginx Image

 

Show the Images

Step 2:  Create a Network with Subnet (CIDR).

Creating Network 

List the Network

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)

       

Inspect Container And Check the Network

 

Output:

Container with Static IP Address

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments