Docker——安装部署(二)

来源:互联网 发布:超级记忆训练软件 编辑:程序博客网 时间:2024/06/07 12:49

一、测试是否已安装docker

[root@localhost ~]# docker-bash: docker: command not found[root@localhost ~]# docker version-bash: docker: command not found[root@localhost ~]# 

二、更换163yum源(可选)

命令: cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.backup
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo CentOS-Base.repo

[root@localhost ~]# cd /etc/yum.repos.d/[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup[root@localhost yum.repos.d]# lsCentOS-Base.repo.backup  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Vault.repo  elrepo.repo  epel.repo  epel-testing.repo  hop5.repo[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo--2017-07-02 00:18:30--  http://mirrors.163.com/.help/CentOS6-Base-163.repoResolving mirrors.163.com... 123.58.173.186, 123.58.173.185Connecting to mirrors.163.com|123.58.173.186|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 2006 (2.0K) [application/octet-stream]Saving to: “CentOS6-Base-163.repo”100%[==================================================================================================================================================================================================>] 2,006       --.-K/s   in 0s      2017-07-02 00:18:30 (451 MB/s) - “CentOS6-Base-163.repo” saved [2006/2006][root@localhost yum.repos.d]# lsCentOS6-Base-163.repo  CentOS-Base.repo.backup  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Vault.repo  elrepo.repo  epel.repo  epel-testing.repo  hop5.repo[root@localhost yum.repos.d]# mv CentOS6-Base-163.repo CentOS-Base.repo[root@localhost yum.repos.d]# lsCentOS-Base.repo  CentOS-Base.repo.backup  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Vault.repo  elrepo.repo  epel.repo  epel-testing.repo  hop5.repo[root@localhost yum.repos.d]# yum clean allLoaded plugins: fastestmirror, refresh-packagekit, securityCleaning repos: base elrepo epel extras updatesCleaning up EverythingCleaning up list of fastest mirrors[root@localhost yum.repos.d]# yum makecacheLoaded plugins: fastestmirror, refresh-packagekit, securityDetermining fastest mirrorsepel/metalink                                                                                                                                                                                                        | 5.7 kB     00:00      * elrepo: hkg.mirror.rackspace.com * epel: mirrors.tuna.tsinghua.edu.cnbase                                                                                                                                                                                                                 | 3.7 kB     00:00     base/group_gz                                                                                                                                                                                                        | 226 kB     00:00     base/filelists_db                                                                                                                                                                                                    | 6.4 MB     00:02     base/primary_db                                                                                                                                                                                                      | 4.7 MB     00:01     base/other_db                                                                                                                                                                                                        | 2.8 MB     00:00     elrepo                                                                                                                                                                                                               | 2.9 kB     00:00     elrepo/filelists_db                                                                                                                                                                                                  |  70 kB     00:00     elrepo/primary_db                                                                                                                                                                                                    | 660 kB     00:00     elrepo/other_db                                                                                                                                                                                                      |  48 kB     00:00     epel                                                                                                                                                                                                                 | 4.3 kB     00:00     epel/filelists_db                                                                                                                                                                                                    | 7.7 MB     00:01     epel/primary_db                                                                                                                                                                                                      | 5.9 MB     00:00     epel/other_db                                                                                                                                                                                                        | 2.9 MB     00:00     extras                                                                                                                                                                                                               | 3.4 kB     00:00     extras/filelists_db                                                                                                                                                                                                  |  25 kB     00:00     extras/prestodelta                                                                                                                                                                                                   | 1.3 kB     00:00     extras/primary_db                                                                                                                                                                                                    |  29 kB     00:00     extras/other_db                                                                                                                                                                                                      |  30 kB     00:00     updates                                                                                                                                                                                                              | 3.4 kB     00:00     updates/filelists_db                                                                                                                                                                                                 | 1.3 MB     00:00     updates/prestodelta                                                                                                                                                                                                  |  50 kB     00:00     updates/primary_db                                                                                                                                                                                                   | 2.0 MB     00:00     updates/other_db                                                                                                                                                                                                     |  25 MB     00:05     Metadata Cache Created[root@localhost yum.repos.d]# 

三、配置Fedora EPEL 源

命令: wget http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum clean all

[root@localhost ~]# wget http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm--2017-07-02 14:40:22--  http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpmResolving mirrors.yun-idc.com... 114.112.43.174Connecting to mirrors.yun-idc.com|114.112.43.174|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 14540 (14K) [application/x-redhat-package-manager]Saving to: “epel-release-6-8.noarch.rpm”100%[==================================================================================================================================================================================================>] 14,540      --.-K/s   in 0.06s   2017-07-02 14:40:22 (253 KB/s) - “epel-release-6-8.noarch.rpm” saved [14540/14540][root@localhost ~]# rpm -ivh epel-release-6-8.noarch.rpmwarning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYPreparing...                ########################################### [100%]   1:epel-release           ########################################### [100%][root@localhost ~]# yum clean allLoaded plugins: fastestmirror, refresh-packagekit, securityCleaning repos: base epel extras updatesCleaning up EverythingCleaning up list of fastest mirrors[root@localhost ~]# 

四、安装docker-io

命令:yum -y install docker-io

[root@localhost ~]# yum -y install docker-ioLoaded plugins: fastestmirror, refresh-packagekit, securitySetting up Install ProcessDetermining fastest mirrorsepel/metalink                                                                                                                                                                                                        | 6.3 kB     00:00      * base: mirrors.cn99.com * epel: mirrors.ustc.edu.cn * extras: mirrors.cn99.com * updates: centos.ustc.edu.cnbase                                                                                                                                                                                                                 | 3.7 kB     00:00     base/primary_db                                                                                                                                                                                                      | 4.7 MB     00:02     epel                                                                                                                                                                                                                 | 4.3 kB     00:00     epel/primary_db                                                                                                                                                                                                      | 5.9 MB     00:00     extras                                                                                                                                                                                                               | 3.4 kB     00:00     extras/primary_db                                                                                                                                                                                                    |  29 kB     00:00     updates                                                                                                                                                                                                              | 3.4 kB     00:00     updates/primary_db                                                                                                                                                                                                   | 2.0 MB     00:00     Resolving Dependencies--> Running transaction check---> Package docker-io.x86_64 0:1.7.1-2.el6 will be installed--> Processing Dependency: lxc for package: docker-io-1.7.1-2.el6.x86_64--> Processing Dependency: libcgroup for package: docker-io-1.7.1-2.el6.x86_64--> Running transaction check---> Package libcgroup.x86_64 0:0.40.rc1-23.el6 will be installed---> Package lxc.x86_64 0:1.0.9-1.el6 will be installed--> Processing Dependency: lua-lxc(x86-64) = 1.0.9-1.el6 for package: lxc-1.0.9-1.el6.x86_64--> Processing Dependency: lua-alt-getopt for package: lxc-1.0.9-1.el6.x86_64--> Processing Dependency: liblxc.so.1()(64bit) for package: lxc-1.0.9-1.el6.x86_64--> Running transaction check---> Package lua-alt-getopt.noarch 0:0.7.0-1.el6 will be installed---> Package lua-lxc.x86_64 0:1.0.9-1.el6 will be installed--> Processing Dependency: lua-filesystem for package: lua-lxc-1.0.9-1.el6.x86_64---> Package lxc-libs.x86_64 0:1.0.9-1.el6 will be installed--> Running transaction check---> Package lua-filesystem.x86_64 0:1.4.2-1.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================================================================================ Package                                                      Arch                                                 Version                                                         Repository                                          Size============================================================================================================================================================================================================================================Installing: docker-io                                                    x86_64                                               1.7.1-2.el6                                                     epel                                               4.6 MInstalling for dependencies: libcgroup                                                    x86_64                                               0.40.rc1-23.el6                                                 base                                               131 k lua-alt-getopt                                               noarch                                               0.7.0-1.el6                                                     epel                                               6.9 k lua-filesystem                                               x86_64                                               1.4.2-1.el6                                                     epel                                                24 k lua-lxc                                                      x86_64                                               1.0.9-1.el6                                                     epel                                                16 k lxc                                                          x86_64                                               1.0.9-1.el6                                                     epel                                               122 k lxc-libs                                                     x86_64                                               1.0.9-1.el6                                                     epel                                               257 kTransaction Summary============================================================================================================================================================================================================================================Install       7 Package(s)Total download size: 5.1 MInstalled size: 20 MDownloading Packages:(1/7): docker-io-1.7.1-2.el6.x86_64.rpm                                                                                                                                                                              | 4.6 MB     00:00     (2/7): libcgroup-0.40.rc1-23.el6.x86_64.rpm                                                                                                                                                                          | 131 kB     00:00     (3/7): lua-alt-getopt-0.7.0-1.el6.noarch.rpm                                                                                                                                                                         | 6.9 kB     00:00     (4/7): lua-filesystem-1.4.2-1.el6.x86_64.rpm                                                                                                                                                                         |  24 kB     00:00     (5/7): lua-lxc-1.0.9-1.el6.x86_64.rpm                                                                                                                                                                                |  16 kB     00:00     (6/7): lxc-1.0.9-1.el6.x86_64.rpm                                                                                                                                                                                    | 122 kB     00:00     (7/7): lxc-libs-1.0.9-1.el6.x86_64.rpm                                                                                                                                                                               | 257 kB     00:00     --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total                                                                                                                                                                                                       3.4 MB/s | 5.1 MB     00:01     warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEYRetrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6Importing GPG key 0x0608B895: Userid : EPEL (6) <epel@fedoraproject.org> Package: epel-release-6-8.noarch (installed) From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYRetrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6Importing GPG key 0xC105B9DE: Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org> Package: centos-release-6-9.el6.12.3.x86_64 (@base/$releasever) From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionWarning: RPMDB altered outside of yum.  Installing : lxc-libs-1.0.9-1.el6.x86_64                                                                                                                                                                                              1/7   Installing : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                                                                                                        2/7   Installing : lua-lxc-1.0.9-1.el6.x86_64                                                                                                                                                                                               3/7   Installing : libcgroup-0.40.rc1-23.el6.x86_64                                                                                                                                                                                         4/7   Installing : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                                                                                                        5/7   Installing : lxc-1.0.9-1.el6.x86_64                                                                                                                                                                                                   6/7   Installing : docker-io-1.7.1-2.el6.x86_64                                                                                                                                                                                             7/7   Verifying  : lua-lxc-1.0.9-1.el6.x86_64                                                                                                                                                                                               1/7   Verifying  : lxc-libs-1.0.9-1.el6.x86_64                                                                                                                                                                                              2/7   Verifying  : lxc-1.0.9-1.el6.x86_64                                                                                                                                                                                                   3/7   Verifying  : docker-io-1.7.1-2.el6.x86_64                                                                                                                                                                                             4/7   Verifying  : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                                                                                                        5/7   Verifying  : libcgroup-0.40.rc1-23.el6.x86_64                                                                                                                                                                                         6/7   Verifying  : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                                                                                                        7/7 Installed:  docker-io.x86_64 0:1.7.1-2.el6                                                                                                                                                                                                            Dependency Installed:  libcgroup.x86_64 0:0.40.rc1-23.el6        lua-alt-getopt.noarch 0:0.7.0-1.el6        lua-filesystem.x86_64 0:1.4.2-1.el6        lua-lxc.x86_64 0:1.0.9-1.el6        lxc.x86_64 0:1.0.9-1.el6        lxc-libs.x86_64 0:1.0.9-1.el6       Complete![root@localhost ~]#

五、检查dockers是否安装成功及版本

命令:docker version

[root@localhost ~]# docker versionClient version: 1.7.1Client API version: 1.19Go version (client): go1.4.2Git commit (client): 786b29d/1.7.1OS/Arch (client): linux/amd64Get http:///var/run/docker.sock/v1.19/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?[root@localhost ~]# 

六、启动docker

命令:service docker start

[root@localhost ~]# service docker startStarting cgconfig service:                                 [  OK  ]Starting docker:                                   [  OK  ][root@localhost ~]#

七、再次执行检查docker版本(发现除了Client还多了一个Server)

命令:docker version

[root@localhost ~]# docker versionClient version: 1.7.1Client API version: 1.19Go version (client): go1.4.2Git commit (client): 786b29d/1.7.1OS/Arch (client): linux/amd64Server version: 1.7.1Server API version: 1.19Go version (server): go1.4.2Git commit (server): 786b29d/1.7.1OS/Arch (server): linux/amd64[root@localhost ~]# 


内链:

Docker——YUM升级centOS内核(一)

Docker——安装部署(二)

Docker——版本升级(三)

Docker——常用命令(四)

Docker——第一个docker服务tomcat(五)

Docker——给tomcat容器部署项目并且做成新的镜像(容器内外拷贝)(六)

原创粉丝点击