Home >Operation and Maintenance >Docker >Does the docker container have an ip?

Does the docker container have an ip?

WBOY
WBOYOriginal
2022-08-15 18:11:463892browse

Docker containers have IPs; docker containers can allocate and specify IPs, especially when building a cluster, which can prevent container IP confusion. When starting a docker container, using the default network does not support assigning a fixed IP, so you need to create a custom network and set a fixed IP.

Does the docker container have an ip?

The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.

Docker containers have IPs?

Yes, docker containers can allocate and specify IPs. Especially when building a cluster, it can prevent container IP confusion.

When starting the docker container, using the default network does not support assigning a fixed IP, so you need to create a custom network and set a fixed IP.

Docker has a compact design, fast deployment and migration, and efficient operation. Applications are independent of each other, and managers can see the contents of all containers. Compared with KVM and the like, the most obvious feature of docker is that it starts quickly and takes up less resources.

Therefore, docker is used to build isolated standardized operating environments, lightweight PaaS, build automated testing and continuous integration environments, and all applications that can be horizontally expanded (especially those that need to start and stop quickly to cope with peaks). Valley web application).

Now more and more cloud service providers are launching their own container technology products. Take Western Digital's container cloud as an example. It is based on docker technology and has tens of thousands of Linux images. It is flexible, powerful, and elastically scalable. , can provide cluster services, support three forms of private network, shared IP network, and exclusive IP network, and support NAT gateway.

Expand knowledge

Steps to configure IP for docker container

1. Check the network mode

docker network ls

2. Create a custom network

docker network create --subnet=网段信息

3. View network information

docker network inspect mynet

4. Create a container and specify the container IP, and select any IP address in the custom network segment As you want to start the container IP

5, run the container, and test whether the machine and the container can ping

When the container stops, docker automatically clears the network card configuration, so eth0 in the container disappears after restarting , the static IP will be invalid. After running a docker container, you can execute the script or pipeline in this article again to reset the IP.

Recommended learning: "docker video tutorial"

The above is the detailed content of Does the docker container have an ip?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn