1.初始环境设置
必要的软件
yum update -y
yum install -y epel-release
yum install -y vim net-tools nmon clamav htop rsync iptraf-ng tree lrzsz cmake make gcc gcc-c++ ntp iftop telnet tcpdump traceroute
设置时间同步
echo "0 8 * * * root ntpdate ntp.southbaytech.co" >> /etc/crontab
关闭selinux及防火墙
sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
禁用DNS反向解析
sed -i 's@GSSAPIAuthentication yes@GSSAPIAuthentication no@' /etc/ssh/sshd_config
sed -i 's@#UseDNS yes@UseDNS no@' /etc/ssh/sshd_config
2.Docker旧版本卸载
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
3.安装Docker CE
安装所需包
yum install -y yum-utils device-mapper-persistent-data lvm2
设置软件源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装
yum install docker-ce docker-ce-cli containerd.io
4.开启Docker
systemctl start docker
通过hello-world镜像验证docker是否安装成功
docker run hello-world
5.镜像加速
vim /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
6.registry服务器安装
- 配置启动文件:
vim config.yml
# 添加以下内容:
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /data/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
auth:
htpasswd:
realm: basic-realm
path: /etc/registry
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
- 启动服务器
docker run -d -p 5000:5000 --restart=always --name registry -v `pwd`/config.yml:/etc/docker/registry/config.yml registry:2