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

How to create a centos container with fixed IP in Docker

藏色散人
Release: 2021-04-15 14:40:34
forward
2462 people have browsed it

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
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

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!

Related labels:
source:segmentfault.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template