When Docker creates a container, it uses the bridge network by default and allocates the IP address by itself, and does not allow you to specify it yourself. In actual deployment, we need to specify the container IP and not allow it to allocate the IP by itself. Especially when building a cluster, a fixed IP is necessary. We can create our own bridge network: mynet. When creating a container, specify the network as mynet and specify the IP. View Network Modedocker network ls Create a new bridge networkdocker network create --driver bridge --subnet=172.18.12.0/16 --gateway=172.18.1.1 mynet View network informationdocker network inspect mynet Create a container and specify the container ipdocker run -e TZ="Asia/Shanghai" --privileged -itd -h hadoop01.com --name hadoop01 --network=mynet --ip 172.18.12.1 centos /usr/sbin/init Running the containerdocker exec -it hadoop01 /bin/bash CentOS minimal installation does not have ifconfig command, it can be installed through yum yum install -y net-tools Install ssh serviceyum install -y openssh-server yum install -y openssh-clients systemctl start sshd.service Add a non-root user useradd brock passwd brock Access through a local client (by specifying a port or configuring an independent IP when creating a container) docker run -e TZ="Asia/Shanghai" -p 6001:22 --privileged -itd -h hadoop01.com --name hadoop01 --network=mynet --ip 172.18.12.1 centos /usr/sbin/init or route -p add 172.18.12.0 MASK 255.255.255.0 10.0.75.2 You may also be interested in:
|
<<: About the difference between inspecting elements and viewing the source code of a web page
>>: Simple implementation of vue drag and drop
There are several ways I know of to set anchor pos...
Arrange by functionNN : Indicates which earlier ve...
What is the nobody user in Unix/Linux systems? 1....
Table of contents 1. Demand 2. Effect 3. All code...
Problem description: The following error message ...
This article shares the specific code of js+Html ...
Error message: ERROR 2002: Can't connect to l...
Table of contents 1. Values within loop objects...
There are three ways to introduce CSS: inline sty...
1 Download the MySQL 5.6 version compressed packa...
It mainly shows how to configure X-Frame-Options,...
01. Command Overview md5sum - Calculate and verif...
Table of contents Overview 1. Dependency Injectio...
Installation Script Ubuntu / CentOS There seems t...
Use the browser (webdriver)-based selenium techno...