Preconditions
CentOS7.6 has been installed minimally in the VM
- install command
- Configure fixed IP
- install docker
- To be added
Install common commands
Use the account password to complete the login, and install the required commands directly at one time to prevent panic when needed.
yum -y install nano vim wget curl net-tools lsof zip unzip
Configure fixed IP
If you use the ip assigned by the virtual machine DHCP, it may change and cause the problem that the shell cannot be connected, so it is best to manually specify
the ip (configure a fixed ip).
Check out the VM's virtual editor
Open the editor of the VM—>virtual network editor——select VMnet8—then select NAT settings—you can see three information
subnet/subnet mask/gateway
Modify linux related configuration files
Main modification content
- Change BOOTPROTO="DHCP" to "static"
- Add 4 configuration
IPADDR fixed IPs at the end: within the range of subnet ip192.168.8.0 to 255, manually specify one, do not repeat the GATEWAY gateway with other existing ips
: it is the found vm gateway
NETMASK subnet mask: 255.255.255.0
DNS1 domain name resolution: 8.8.8.8
vim /etc/sysconfig/network-scripts/ifcfg-ens33
----------------------------------------------------------------------------
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" # 修改为static , 由DHCP动态分配, 变为静态指定ip
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="0cf08bf1-4d39-4cc7-b257-dddss875954"
DEVICE="ens33"
ONBOOT="yes"
# 文件末尾添加
IPADDR=192.168.8.190 # 此处ip 可以手动指定固定的ip , 但不要和其它虚拟机ip重复.
GATEWAY=192.168.8.2 # 查到的VM网关
NETMASK=255.255.255.0 # 查到的VM子网掩码
DNS1=8.8.8.8 # 谷歌的DNS解析
Restart the system for the configuration to take effect
reboot
install docker
Install the docker body
1. 下载docker的依赖环境
yum install -y yum-utils device-mapper-persistent-data lvm2
2. 设置docker的阿里云镜像源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3.安装docker
yum makacache fast
yum -y install docker-ce
4.启动docker并设置开机自启动
启动: systemctl start docker
开机自动启动: systemctl enable docker
5.测试docker是否安装成功
docker run hello-world
Install docker-compose
#下载docker-compose 1.24.1版本
wget https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-x86_64
# 放入指定目录
mv docker-compose-Linux-x86_64 /usr/local/bin
# 切到目录
cd /usr/local/bin
# 改名方便操作
mv docker-compose-Linux-x86_64 docker-compose
# 开启权限
chmod 777 docker-compose
# 添加环境变量
vim /etc/profile
末尾添加 export=/usr/local/bin
wq保存退出
# 刷新
source /etc/profile