类型 | 配置 |
CPU | 8核 |
内存 | 64G |
硬盘 | 500G |
操作系统 | Centos7 64位 |
yum install -y wget \
&& mkdir -p /etc/yum.repos.d/repo_bak \
&& mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/repo_bak/ \
&& wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \
&& wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo \
&& yum clean all \
&& yum makecache \
&& yum update -y
yum install -y yum-utils device-mapper-persistent-data lvm2 \
&& yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo\
&& yum makecache fast \
&& yum -y install docker-ce \
&& yum clean all \
&& docker version
执行结果
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:21:07 2019
OS/Arch: linux/amd64
Experimental: false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
非必填,按需添加
data-root:docker根目录路径
insecure-registries:docker私有仓库地址
registry-mirrors:公共镜像仓库加速地址
mkdir -p /etc/docker/ && \
(
cat <>/etc/docker/daemon.json \
&& systemctl start docker \
&& systemctl enable docker \
&& cat /etc/docker/daemon.json \
&& docker version
执行结果
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
{
"data-root":"/home/docker",
"insecure-registries": ["ops.cn:5000"],
"registry-mirrors": ["https://1e7waog4.mirror.aliyuncs.com"]
}
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:21:07 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.12)
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:19:36 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683
#安装docker命令补全工具
yum install -y bash-completion \
&& source /usr/share/bash-completion/completions/docker \
&& source /usr/share/bash-completion/bash_completion \
&& yum clean all
Installed:
bash-completion.noarch 1:2.1-6.el7
yum install -y vim wget ntp net-tools \
&& yum clean all
systemctl stop firewalld \
&& systemctl disable firewalld \
&& systemctl status firewalld
执行结果:
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
setenforce 0 \
|| sed -i 's/enforcing/disabled/g' /etc/selinux/config \
&& sed -i 's/permissive/disabled/g' /etc/selinux/config \
&& getenforce
执行结果:
setenforce: SELinux is disabled
Disabled
vim /etc/ntp.conf
# 将时钟服务器更改为如下4个
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org
启动设置ntp服务:
systemctl start ntpd \
&& systemctl enable ntpd \
&& ntpdate -u 0.cn.pool.ntp.org \
&& hwclock --systohc \
&& date
执行结果
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
14 Aug 09:43:05 ntpdate[27529]: adjust time server 192.168.1.201 offset 0.003912 sec
Wed Aug 14 09:43:06 CST 2019
9、创建自定义网络
docker network create --subnet=172.10.0.0/16 hadoop_net \
&& docker network ls
执行结果
[root@iZ8vb95gtlfw61s1qhl62vZ ~]# docker network create --subnet=172.10.0.0/16 hadoop_net \
> && docker network ls
44abb1d199cf791d4f70bd2e2a83a1a079de1f1bc68f4a6044a62619a8f2ac02
NETWORK ID NAME DRIVER SCOPE
a0ac21500a51 bridge bridge local
44abb1d199cf hadoop_net bridge local
67d4fcd891ff host host local
45cbe53ff236 none null local
10、下载Centos镜像
docker pull centos7 \
&& docker images
11、启动容器
docker run -d \
--add-host cm.hadoop:172.10.0.2 \
--net hadoop_net \
--ip 172.10.0.2 \
-h cm.hadoop \
-p 10022:22 \
-p 7180:7180 \
--restart always \
--name cm.hadoop \
--privileged \
ops.cn:5000/centos \
/usr/sbin/init \
&& docker ps
执行结果
368bd10d9e53be08dd3ec424c49989268798e4ad4c2b7d09570ab9d81680cdcc
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
368bd10d9e53 ops.cn:5000/centos "/usr/sbin/init" 1 second ago Up Less than a second 0.0.0.0:7180->7180/tcp, 0.0.0.0:10022->22/tcp cm.hadoop