文章目录
Docker 的运行环境
Docker 可以运行在 Linux、Windows 、Mac OS 操作系统上。
Docker 官方建议安装在 Linux 操作系统。
Docker 在 Mac OS的安装(如果启动软件,在终端运行 docker run hello-world 报错,则选择一个低版本的安装)
https://dockerdocs.cn/ => https://dockerdocs.cn/get-docker/index.html
- 配置Docker-Engine 的 registry-mirrors ,进行镜像加速
{
"builder": {
"features": {
"buildkit": true
},
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"http://hub-mirror.c.163.com"
]
}
Windows 环境的安装
·安装完毕后需要关联虚拟机:https://www.jianshu.com/p/06009c2fa7f2
1、windows环境下有专门的docker工具
可以从阿里云镜像下载安装包:http://mirrors.aliyun.com/docker-
toolbox/windows/docker-toolbox/
windows 找不到 bash.exe
Default Boot2Docker ISO is out-of-date-断网即可跳过
This error may also indicate that the docker daemon is not running.
This computer doesn’t have VT-X/AMD-v enabled .Enabling it in the BIOS is mandatory
2、镜像加速
鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决,网易的镜像地址:http://hub-mirror.c.163.com
也可以使用阿里云,它会给你提供一个独立的域名
新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config
\daemon.json(Windows) 来配置 Daemon。
请在该配置文件中加入(没有该文件的话,请先建一个):
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
Docker 在Cent OS 上的安装
系统版本要求
- Cent OS 版本需要为 7.X 及以上
- Cent OS 需为 64位操作系统
多种安装方式的选择
Docker 有多种安装方式,比如 Yum 安装、RPM 安装、Shell 安装等。
Yum 安装 Docker
注意:需要
root
权限,本文使用root
用户登陆,如非 root 用户请在命令行前添加sudo
前缀。
- 更新yum包
注意:该步骤不是必须的,需要花费一些时间
yum update
- 添加 yum 的 Docker 包仓库
tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
- 安装 Docker 引擎
注意:中途有两个确认 输入 y 然后按 Enter:Is this ok [y/d/N]: 和 Is this ok [y/N]:
yum install docker-engine
安装完 Docker 之后,可以查看安装版本!
- 查看 Docker 版本
docker version
Docker 引擎服务的启动和关闭
- 启动 Docker 引擎服务
首次启动自动创建文件夹 /var/lib/docker
/var/lib/docker/image/overlay/repositories.json 镜像目录
/var/lib/docker/containers 存储具体镜像
service docker start
- 关闭 Docker 引擎服务
service docker stop
Docker 引擎的卸载
卸载 Docker 引擎不会删除镜像、容器、卷及自定义的配置文件!
- 卸载 Docker 引擎
yum -y remove docker-engine
- 删除镜像、容器、卷及自定义的配置文件
rm -rf /var/lib/docker
Dockerfile 镜像构建参考文档:https://docs.docker.com/engine/reference/builder/?spm=5176.8351553.0.0.40f61991NPF2oT
参考资料
[1]、https://648gfzys.mirror.aliyuncs.com