1. 更新yum
yum update
2. 安装docker
安装
yum install -y docker
修改镜像地址,编辑/etc/docker/daemon.json
{
"registry-mirrors": ["https://uulfe4bd.mirror.aliyuncs.com"]
}
systemctl start docker
排查错误
1.启动报错
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
2.查看错误日志
# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 六 2018-04-21 01:34:30 PDT; 1min 1s ago
Docs: http://docs.docker.com
Process: 109164 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 109164 (code=exited, status=1/FAILURE)
CGroup: /system.slice/docker.service
4月 21 01:34:28 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
4月 21 01:34:28 localhost.localdomain dockerd-current[109164]: time="2018-04-21T01:34:28.627482523-07:00" level=info msg="libcontainerd: new...09176"
4月 21 01:34:29 localhost.localdomain dockerd-current[109164]: time="2018-04-21T01:34:29.647444993-07:00" level=warning msg="overlay2: the backing...
4月 21 01:34:30 localhost.localdomain dockerd-current[109164]: Error starting daemon: SELinux is not supported with the overlay2 graph drive...false)
4月 21 01:34:30 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
4月 21 01:34:30 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
4月 21 01:34:30 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
4月 21 01:34:30 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
3.解决方案
# vi /etc/sysconfig/docker
修改option为:
OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false'
原因:
此linux的内核中的SELinux不支持 overlay2 graph driver ,解决方法有两个,要么启动一个新内核,要么就在docker里禁用selinux,--selinux-enabled=false
3. 安装镜像
安装centos 镜像
docker pull registry.cn-hangzhou.aliyuncs.com/moensun/centos7
创建容器
docker run -dit 3db94df3e006 /usr/sbin/init
启动容器
docker start 4843791bbb20
进入容器
docker exec -it 4843791bbb20 /bin/bash
4. 容器安装mysql
1 下载安装包
wget
2 从主机复制到 容器中
docker cp mysql57-community-release-el7-10.noarch.rpm mysql_master_01:/root
3. 安装其他引用包
yum install -y perl perl-Module-Build net-tools autoconf libaio numactl-libs
- 安装包
rpm -ivh mysql57-community-release-el7-10.noarch.rpm
- 安装mysql
yum install mysql-server