Pull the image
docker pull centos
Copy after login
Create a custom network
docker network create --subnet=172.18.0.0/16 mynetwork
Copy after login
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
Copy after login
View the details of the docker container (including IP)
docker ps docker inspect 容器ID或容器名称
Copy after login