1.安装docker: yum -y install docker-io
2.启动并设置开机自动启动: service docker start chkconfig docker on
3. 拉取镜像 docker pull centos:latest
拉取中需要使用daoclound加速:curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://261a72f8.m.daocloud.io
4.启动镜像 docker run --name=''(自定义名称)+ 镜像名 + 启动参数 例如: docker run --name=test01 -i -t centos /bin/bash
5.退出命令 exit 或者 Ctrl+P+Q(后台运行)
6.重新回到容器 docker attach + 容器名称 例如 docker attach test01
安装过程中可能存在的问题:
问题描述:安装完成后,service docker start不能正常启动 此时通过systemctl status docker.service 查看问题 Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel
解决办法:
# /etc/sysconfig/docker
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi