- centos7安装 docker
切换到 root用户,执行:
[root@localhost frinder]# yum install docker
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
--> 解决依赖关系完成
依赖关系解决
=================================================================================================================================================================
Package 架构 版本 源 大小
=================================================================================================================================================================
正在安装:
docker x86_64 2:1.12.6-11.el7.centos extras 20 M
为依赖而安装:
container-selinux noarch 2:2.9-4.el7 extras 26 k
docker-client x86_64 2:1.12.6-11.el7.centos extras 4.4 M
docker-common x86_64 2:1.12.6-11.el7.centos extras 71 k
oci-register-machine x86_64 1:0-1.11.gitdd0daef.el7 extras 1.1 M
oci-systemd-hook x86_64 1:0.1.4-9.git671c428.el7 extras 29 k
skopeo-containers x86_64 1:0.1.18-1.el7 extras 7.6 k
事务概要
=================================================================================================================================================================
安装 1 软件包 (+6 依赖软件包)
总下载量:26 M
安装大小:104 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/extras/packages/container-selinux-2.9-4.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
container-selinux-2.9-4.el7.noarch.rpm 的公钥尚未安装
(1/7): container-selinux-2.9-4.el7.noarch.rpm | 26 kB 00:00:00
(2/7): docker-client-1.12.6-11.el7.centos.x86_64.rpm | 4.4 MB 00:00:04
(3/7): docker-common-1.12.6-11.el7.centos.x86_64.rpm | 71 kB 00:00:00
(4/7): oci-register-machine-0-1.11.gitdd0daef.el7.x86_64.rpm | 1.1 MB 00:00:01
(5/7): oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64.rpm | 29 kB 00:00:00
(6/7): skopeo-containers-0.1.18-1.el7.x86_64.rpm | 7.6 kB 00:00:00
(7/7): docker-1.12.6-11.el7.centos.x86_64.rpm | 20 MB 00:00:13
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 1.9 MB/s | 26 MB 00:00:13
从 http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
来自 : http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : 2:docker-common-1.12.6-11.el7.centos.x86_64 1/7
正在安装 : 2:docker-client-1.12.6-11.el7.centos.x86_64 2/7
正在安装 : 1:oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64 3/7
正在安装 : 1:oci-register-machine-0-1.11.gitdd0daef.el7.x86_64 4/7
正在安装 : 1:skopeo-containers-0.1.18-1.el7.x86_64 5/7
正在安装 : 2:container-selinux-2.9-4.el7.noarch 6/7
正在安装 : 2:docker-1.12.6-11.el7.centos.x86_64 7/7
验证中 : 2:container-selinux-2.9-4.el7.noarch 1/7
验证中 : 2:docker-1.12.6-11.el7.centos.x86_64 2/7
验证中 : 1:skopeo-containers-0.1.18-1.el7.x86_64 3/7
验证中 : 1:oci-register-machine-0-1.11.gitdd0daef.el7.x86_64 4/7
验证中 : 2:docker-common-1.12.6-11.el7.centos.x86_64 5/7
验证中 : 2:docker-client-1.12.6-11.el7.centos.x86_64 6/7
验证中 : 1:oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64 7/7
已安装:
docker.x86_64 2:1.12.6-11.el7.centos
作为依赖被安装:
container-selinux.noarch 2:2.9-4.el7 docker-client.x86_64 2:1.12.6-11.el7.centos docker-common.x86_64 2:1.12.6-11.el7.centos
oci-register-machine.x86_64 1:0-1.11.gitdd0daef.el7 oci-systemd-hook.x86_64 1:0.1.4-9.git671c428.el7 skopeo-containers.x86_64 1:0.1.18-1.el7
完毕!
启动 docker,执行:
[root@localhost frinder]# systemctl start docker.service
将 docker设置开机启动:
[root@localhost frinder]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
下载 docker使用 Centos镜像,下载有点慢,耐心等待:
[root@localhost docker]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
93857f76ae30: Pull complete
Digest: sha256:4eda692c08e0a065ae91d74e82fff4af3da307b4341ad61fa61771cc4659af60
查看下载镜像:
[root@localhost docker]# docker images centos
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest a8493f5f50ff 3 days ago 192.5 MB
使用 docker启动一个容器,启动成功会自动切换到临时容器 54d23ded3cd1:
[root@localhost docker]# docker run -i -t docker.io/centos /bin/bash
[root@54d23ded3cd1 /]#
[root@54d23ded3cd1 /]# ls /etc
BUILDTIME chkconfig.d gnupg issue.net modules-load.d popt.d rc5.d shells virc
DIR_COLORS crypttab group krb5.conf motd prelink.conf.d rc6.d skel xdg
DIR_COLORS.256color csh.cshrc group- krb5.conf.d mtab printcap redhat-release ssl xinetd.d
DIR_COLORS.lightbgcolor csh.login gshadow ld.so.cache nsswitch.conf profile resolv.conf subgid yum
GREP_COLORS dbus-1 gshadow- ld.so.conf nsswitch.conf.bak profile.d rpc subuid yum.conf
X11 default gss ld.so.conf.d openldap protocols rpm sysconfig yum.repos.d
adjtime.rpmsave depmod.d host.conf libaudit.conf opt python rsyslog.d sysctl.d
aliases dracut.conf hostname libuser.conf os-release rc.d sasl2 system-release
alternatives dracut.conf.d hosts locale.conf pam.d rc.local securetty system-release-cpe
bash_completion.d environment hosts.allow localtime passwd rc0.d security systemd
bashrc exports hosts.deny login.defs passwd- rc1.d selinux terminfo
binfmt.d filesystems init.d logrotate.d pkcs11 rc2.d services tmpfiles.d
centos-release fstab inputrc machine-id pki rc3.d shadow udev
centos-release-upstream gcrypt issue modprobe.d pm rc4.d shadow- vconsole.conf
[root@54d23ded3cd1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@54d23ded3cd1 /]# exit