Docker 软件包已经包括在默认的 CentOS-Extras 软件源里。因此想要安装 docker,只需要运行下面的 yum 命令:

[root@localhost ~]# yum install docker

启动 Docker 服务
安装完成后,使用下面的命令来启动 docker 服务,并将其设置为开机启动:

[root@localhost ~]# service docker start
[root@localhost ~]# chkconfig docker on

(LCTT 译注:此处采用了旧式的 sysv 语法,如采用CentOS 7中支持的新式 systemd 语法,如下:

[root@localhost ~]# systemctl start docker.service
[root@localhost ~]# systemctl enable docker.service

下载官方的 CentOS 镜像到本地

[root@localhost ~]# docker pull centos
Pulling repository centos
192178b11d36: Download complete
70441cac1ed5: Download complete
ae0c2d0bdc10: Download complete
511136ea3c5a: Download complete
5b12ef8fd570: Download complete

确认 CentOS 镜像已经被获取:

[root@localhost ~]# docker images centos
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
centos centos5 192178b11d36 2 weeks ago 466.9 MB
centos centos6 70441cac1ed5 2 weeks ago 215.8 MB
centos centos7 ae0c2d0bdc10 2 weeks ago 224 MB
centos latest ae0c2d0bdc10 2 weeks ago 224 MB

运行一个 Docker 容器:

[root@localhost ~]# docker run -i -t centos /bin/bash
[root@dbf66395436d /]#

我们可以看到,CentOS 容器已经被启动,并且我们得到了 bash 提示符。在 docker 命令中我们使用了 “-i 捕获标准输入输出”和 “-t 分配一个终端或控制台”选项。若要断开与容器的连接,输入 exit。

[root@cd05639b3f5c /]# cat /etc/redhat-release 
CentOS Linux release 7.0.1406 (Core) 
[root@cd05639b3f5c /]# exit
exit
[root@localhost ~]#

我们还可以搜索基于 Fedora 和 Ubuntu 操作系统的容器。

[root@localhost ~]# docker search ubuntu
[root@localhost ~]# docker search fedora
标签:
linux,docker安装,linux安装docker

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“linux中docker的安装教程”

暂无“linux中docker的安装教程”评论...

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。