Home  >  Article  >  Operation and Maintenance  >  How to create a centos container with fixed IP in Docker

How to create a centos container with fixed IP in Docker

藏色散人
藏色散人forward
2021-04-15 14:40:342346browse

The following tutorial column from centos will introduce Docker to create a centos container with a fixed IP. I hope it will be helpful to friends in need!

How to create a centos container with fixed IP in Docker

Docker creates a centos container with a fixed IP

Pull the image

docker pull centos

Create a custom network

docker network create --subnet=172.18.0.0/16 mynetwork

Start the centos container with fixed IP

docker run -itd --privileged --name centos1 --net mynetwork --ip 172.18.0.11 centos:latest /usr/sbin/init
docker run -itd --privileged --name centos2 --net mynetwork --ip 172.18.0.12 centos:latest /usr/sbin/init
docker run -itd --privileged --name centos3 --net mynetwork --ip 172.18.0.13 centos:latest /usr/sbin/init

View the details of the docker container (including IP)

docker ps
docker inspect 容器ID或容器名称

The above is the detailed content of How to create a centos container with fixed IP in Docker. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete