

CentOS7环境下安装docker
source link: https://www.cnblogs.com/MikeZhang/p/centos7_install_docker_20191117.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

CentOS7环境下安装docker
操作系统 : CentOS7.5.1804_x64
docker版本: docker-ce-18.06.3
1、如之前安装过移除老旧版本
yum remove docker docker-client docker-client-latest docker-common docker-latest \ docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine
2、使用阿里镜像库安装
# 安装必要的一些系统工具 yum install -y yum-utils device-mapper-persistent-data lvm2 # 添加软件源信息 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 更新cache yum makecache fast
安装docker
# 查看所有仓库中所有docker版本,并选择特定版本安装 yum list docker-ce --showduplicates | sort -r # 安装docker(这里选择 18.06.3 版本) yum install -y docker-ce-18.06.3.ce-3.el7
# 启动 systemctl start docker # 开机启动 systemctl enable docker
3、验证是否安装成功
[root@host26 ~]# docker version Client: Version: 18.06.3-ce API version: 1.38 Go version: go1.10.3 Git commit: d7080c1 Built: Wed Feb 20 02:26:51 2019 OS/Arch: linux/amd64 Experimental: false Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? [root@host26 ~]#
使用docker镜像
1、配置镜像加速
对应文件 : /etc/docker/daemon.json
没有则创建,内容如下:
{ "registry-mirrors": [ "https://dockerhub.azk8s.cn", "https://reg-mirror.qiniu.com" ] }
重新启动服务
systemctl daemon-reload && systemctl restart docker
检查加速器是否生效
执行 docker info 命令,如果从结果中看到了如下内容,说明配置成功。
Registry Mirrors: https://dockerhub.azk8s.cn/ https://reg-mirror.qiniu.com/ Live Restore Enabled: false
2、使用镜像
获取镜像,示例如下:
[root@host26 dk]# docker pull ubuntu:18.04 18.04: Pulling from library/ubuntu 5667fdb72017: Pull complete d83811f270d5: Pull complete ee671aafb583: Pull complete 7fc152dfb3a6: Pull complete Digest: sha256:b88f8848e9a1a4e4558ba7cfc4acc5879e1d0e7ac06401409062ad2627e6fb58 Status: Downloaded newer image for ubuntu:18.04 [root@host26 dk]# ls [root@host26 dk]# ll -h total 0 [root@host26 dk]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 18.04 2ca708c1c9cc 6 days ago 64.2MB [root@host26 dk]#
使用镜像,示例如下:
[root@host26 dk]# docker run -t -i ubuntu:18.04 /bin/bash root@6c1d0cdbbaaf:/# cat /etc/issue Ubuntu 18.04.3 LTS \n \l root@6c1d0cdbbaaf:/#
参数说明:
-i: 交互式操作。 -t: 终端。 ubuntu:18.04 : 这是指用 ubuntu 18.04 版本镜像为基础来启动容器。 /bin/bash:放在镜像名后的是命令,这里我们希望有个交互式 Shell,因此用的是 /bin/bash。
本文github地址:
https://github.com/mike-zhang/mikeBlogEssays/blob/master/2019/20191117_CentOS7环境下安装docker.rst
Recommend
-
9
最近,我自己要亲手搭建一套完整的企业级 CI/CD 环境,这个环节里面涉及了很多内容,没有办法把这么多的内容都放在一篇文章里,所以 Jenkins 的安装和Java 的 JDK 安装我就是分了两篇文章来写的。而且这套环境中...
-
7
作者:三十三重天 博客:http://www.zhouhuibo.club 通过学习和分享的过程,将自己工作中的问题和技术总结输出,希望菜鸟和老鸟...
-
4
CentOS7安装docker-ce(阿里源) 2020-01-08 Linux Docker 官方教程:https://docs.docker.com/engine/install/centos/...
-
6
V2EX › Python centos7 django+nginx 环境下的网站经常性的出现:无法访问此网站 xxxxx.com 的响应时间太长。。。...
-
10
宝塔面板Centos7环境下如何使Python2与Python3共存 2021-11-2314:09:12
-
5
Centos7下搭建Laravel环境 发表于...
-
4
服务器上的 Docker 是 1.13 版本的有点老了,于是打算升级一下; 结果发现加入了 Docker 源之后使用 yum 安装报错了…,这里总结一下; centos7中使用yum安装docker报错解决方法
-
7
CentOS7 / Docker 环境安装 GitLab-CE 2022/12/31 Linux Docker Git 安装所需最小内存为 4G ,推荐内存为 8G CentOS7
-
4
在Centos7.6上部署Docker环境以及安装docker-compose首页 - Mac & Linux/2019-08-21 毫无疑问,Do...
-
5
CentOS7环境安装Harbor(docker私服) 麦克斯仇 Think different ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK