1 #查看内核的版本 2 uname -r(>=3.1.0) 3 #查看centos版本 4 cat /etc/redhat-release(>=6.5) 5 #安装依赖 6 yum install -y yum-utils device-mapper-persistent-data lvm2 7 #给yum 设置稳定的仓库员源 8 yum-config-manager 9 --add-repo 10 https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
11 #开始安装 12 yum install -y docker-ce(新版的18.09docker是docker-ce) 13 #启动docker 14 systemctl restart docker
1 #查找docker安装包 2 yum list installed | grep docker 3 #将查询到的包全部删除 4 yum remove package(包) 5 #删除保存镜像的文件 6 rm -rf /var/lib/docker
3. docker 三要素
镜像
容器
仓库
4. docker镜像
docker的基石,一般由Dockerfile生成,https://hub.docker.com/ docker hub网站存放各种镜像,可以直接使用
docker镜像的基本操作
# 搜索镜像
docker search hello-world(一般可以直接去docker hub上去搜各种详细带标签的镜像)
#从docker hub 上面拉取hello-world镜像 docker pull hello-world #查看本地所有的镜像 docker images docker iamges -q 只显示镜像id
# 查看镜像的历史层数
docker history hello-world
#查看镜像的详细信息
docker inapect hello-world
#删除某个镜像 docker rmi hello-world(-f 强制删除) # 删除所有的镜像 docker rmi $(docker images -aq) #注册docker hub 账户 账户名假设为xiaoxiaohui #给镜像 打tag docker tag hello-world xiaoxiaohui/hello-world #将该镜像推送到自己的仓库 docker push xiaoxiaohui/hello-world
默认推送到docker hub 仓库镜像,如果自己有其他仓库地址 需要先登录 docker login 地址
#镜像的导入导出
将已有的镜像保存为一个文件
docker save hello-world -o 文件名
将文件导出为镜像 docker load -i 文件名
5. 镜像的构建
两种方法
docker commit 命令 基于已有的容器构建镜像,不推荐
Dockerfile 一种文件 详细描述该镜像如何构建 docke build .
Dockerfile 如何书写 见下一篇
6.容器
容器在镜像的基础上加了一个可写层,是基于镜像模板创建出来的一个个实例
原文:https://www.cnblogs.com/fayuzhang/p/11136022.html