CentOS 7 上安装 Docker

来源:互联网 发布:2010年流行网络歌曲 编辑:程序博客网 时间:2024/05/22 10:02

from:

http://www.linuxidc.com/Linux/2014-12/110034.htm

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

[root@localhost ~]# yum install docker

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

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

下载官方的 CentOS 镜像到本地

[root@localhost ~]# docker pull centos

确认 CentOS 镜像已经被获取:

[root@localhost ~]# docker images centos

运行一个 Docker 容器:

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

[root@dbf66395436d /]#

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

[root@cd05639b3f5c /]# cat /etc/RedHat-release
CentOSLinux release 7.0.1406(Core)
[root@cd05639b3f5c /]#exit
exit
[root@localhost ~]#