一、安装docker

1.搜索docker

[root@node3 ~]# yum search docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
========================================================================== N/S matched: docker ===========================================================================
cockpit-docker.x86_64 : Cockpit user interface for Docker containers
docker-client.x86_64 : Client side files for Docker
docker-client-latest.x86_64 : Client side files for Docker
docker-common.x86_64 : Common files for docker and docker-latest
docker-distribution.x86_64 : Docker toolset to pack, ship, store, and deliver content
docker-latest-logrotate.x86_64 : cron job to run logrotate on Docker containers
docker-latest-v1.-migrator.x86_64 : Calculates SHA256 checksums for docker layer content
docker-logrotate.x86_64 : cron job to run logrotate on Docker containers
docker-lvm-plugin.x86_64 : Docker volume driver for lvm volumes
docker-python.x86_64 : An API client for docker written in Python
docker-registry.noarch : Registry server for Docker
docker-registry.x86_64 : Registry server for Docker
docker-v1.-migrator.x86_64 : Calculates SHA256 checksums for docker layer content
python-docker-py.noarch : An API client for docker written in Python
python-docker-pycreds.noarch : Python bindings for the docker credentials store API
docker.x86_64 : Automates deployment of containerized applications
docker-devel.x86_64 : A golang registry for global request variables (source libraries)
docker-forward-journald.x86_64 : Forward stdin to journald
docker-latest.x86_64 : Automates deployment of containerized applications
docker-novolume-plugin.x86_64 : Block container starts with local volumes defined
docker-unit-test.x86_64 : Automates deployment of containerized applications - for running unit tests
oci-systemd-hook.x86_64 : OCI systemd hook for docker
oci-umount.x86_64 : OCI umount hook for docker
skopeo.x86_64 : Inspect Docker images and repositories on registries Name and summary matches only, use "search all" for everything.

2.安装docker

[root@node3 ~]# yum install -y docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 :1.12.-.git88a4867.el7.centos will be installed
--> Processing Dependency: docker-common = :1.12.-.git88a4867.el7.centos for package: :docker-1.12.-.git88a4867.el7.centos.x86_64
....
....
---> Package systemd-libs.x86_64 :-.el7_3. will be an update
---> Package systemd-python.x86_64 :-.el7 will be updated
---> Package systemd-python.x86_64 :-.el7_3. will be an update
---> Package systemd-sysv.x86_64 :-.el7 will be updated
---> Package systemd-sysv.x86_64 :-.el7_3. will be an update
--> Running transaction check
---> Package libgudev1.x86_64 :-.el7 will be updated
---> Package libgudev1.x86_64 :-.el7_3. will be an update
--> Finished Dependency Resolution Dependencies Resolved ==========================================================================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================================================================
Installing:
docker x86_64 :1.12.-.git88a4867.el7.centos extras M
Updating:
selinux-policy-targeted noarch 3.13.-.el7_3. updates 6.4 M
systemd x86_64 -.el7_3. updates 5.2 M
Installing for dependencies:
container-selinux noarch :2.19-2.1.el7 extras k
docker-client x86_64 :1.12.-.git88a4867.el7.centos extras 3.2 M
docker-common x86_64 :1.12.-.git88a4867.el7.centos extras k
oci-register-machine x86_64 :-3.11.gitdd0daef.el7 extras 1.0 M
oci-systemd-hook x86_64 :0.1.-.gite533efa.el7 extras k
skopeo-containers x86_64 :0.1.-.el7 extras 7.8 k
Updating for dependencies:
libgudev1 x86_64 -.el7_3. updates k
libselinux x86_64 2.5-.el7 base k
libselinux-devel x86_64 2.5-.el7 base k
libselinux-python x86_64 2.5-.el7 base k
libselinux-utils x86_64 2.5-.el7 base k
libsemanage x86_64 2.5-5.1.el7_3 updates k
libsemanage-python x86_64 2.5-5.1.el7_3 updates k
libsepol x86_64 2.5-.el7 base k
libsepol-devel x86_64 2.5-.el7 base k
policycoreutils x86_64 2.5-.el7_3 updates k
policycoreutils-python x86_64 2.5-.el7_3 updates k
selinux-policy noarch 3.13.-.el7_3. updates k
setools-libs x86_64 3.3.-1.1.el7 base k
systemd-libs x86_64 -.el7_3. updates k
systemd-python x86_64 -.el7_3. updates k
systemd-sysv x86_64 -.el7_3. updates k Transaction Summary
==========================================================================================================================================================================
Install Package (+ Dependent packages)
Upgrade Packages (+ Dependent packages) Total size: M
Total download size: M
Downloading packages:
Delta RPMs reduced 7.0 M of updates to 3.9 M (% saved)
(/): policycoreutils-python-2.2.-.el7_2.-.el7_3.x86_64.drpm | kB ::
(/): policycoreutils-2.2.-.el7_2.-.el7_3.x86_64.drpm | kB ::
(/): systemd-libs--.el7_219-.el7_3..x86_64.drpm | kB ::
(/): systemd-python--.el7_219-.el7_3..x86_64.drpm | kB ::
(/): container-selinux-2.19-2.1.el7.noarch.rpm | kB ::
(/): docker-client-1.12.-.git88a4867.el7.centos.x86_64.rpm | 3.2 MB ::
(/): docker-common-1.12.-.git88a4867.el7.centos.x86_64.rpm | kB ::
(/): libgudev1--.el7_3..x86_64.rpm | kB ::
(/): libsemanage-2.5-5.1.el7_3.x86_64.rpm | kB ::
(/): libsemanage-python-2.5-5.1.el7_3.x86_64.rpm | kB ::
(/): systemd--.el7_219-.el7_3..x86_64.drpm | 3.0 MB ::
(/): oci-register-machine--3.11.gitdd0daef.el7.x86_64.rpm | 1.0 MB ::
(/): oci-systemd-hook-0.1.-.gite533efa.el7.x86_64.rpm | kB ::
(/): skopeo-containers-0.1.-.el7.x86_64.rpm | 7.8 kB ::
(/): selinux-policy-3.13.-.el7_3..noarch.rpm | kB ::
(/): systemd-sysv--.el7_3..x86_64.rpm | kB ::
(/): selinux-policy-targeted-3.13.-.el7_3..noarch.rpm | 6.4 MB ::
(/): docker-1.12.-.git88a4867.el7.centos.x86_64.rpm | MB ::
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.0 MB/s | MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libsepol-2.5-.el7.x86_64 /
Updating : libselinux-2.5-.el7.x86_64
....
.... /
Verifying : policycoreutils-python-2.2.-.el7.x86_64 / Installed:
docker.x86_64 :1.12.-.git88a4867.el7.centos Dependency Installed:
container-selinux.noarch :2.19-2.1.el7 docker-client.x86_64 :1.12.-.git88a4867.el7.centos docker-common.x86_64 :1.12.-.git88a4867.el7.centos
oci-register-machine.x86_64 :-3.11.gitdd0daef.el7 oci-systemd-hook.x86_64 :0.1.-.gite533efa.el7 skopeo-containers.x86_64 :0.1.-.el7 Updated:
selinux-policy-targeted.noarch :3.13.-.el7_3. systemd.x86_64 :-.el7_3. Dependency Updated:
libgudev1.x86_64 :-.el7_3. libselinux.x86_64 :2.5-.el7 libselinux-devel.x86_64 :2.5-.el7 libselinux-python.x86_64 :2.5-.el7
libselinux-utils.x86_64 :2.5-.el7 libsemanage.x86_64 :2.5-5.1.el7_3 libsemanage-python.x86_64 :2.5-5.1.el7_3 libsepol.x86_64 :2.5-.el7
libsepol-devel.x86_64 :2.5-.el7 policycoreutils.x86_64 :2.5-.el7_3 policycoreutils-python.x86_64 :2.5-.el7_3 selinux-policy.noarch :3.13.-.el7_3.
setools-libs.x86_64 :3.3.-1.1.el7 systemd-libs.x86_64 :-.el7_3. systemd-python.x86_64 :-.el7_3. systemd-sysv.x86_64 :-.el7_3. Complete!
[root@node3 ~]#

二、启动docker

1.启动命令

[root@node3 ~]# systemctl start docker

2.查看状态

[root@node3 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Mon -- :: CST; 4s ago
Docs: http://docs.docker.com
Main PID: (dockerd-current)
CGroup: /system.slice/docker.service
├─ /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdri...
└─ /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0... Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.414920983+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.415711385+08:00" level=warning msg="mountpoint for pids not found"
Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.416487662+08:00" level=info msg="Loading containers: start."
Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.429707075+08:00" level=info msg="Firewalld running: false"
Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.638641730+08:00" level=info msg="Default bridge (docker0) is assigned with an IP addr...P address"
Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.780057349+08:00" level=info msg="Loading containers: done."
Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.780334779+08:00" level=info msg="Daemon has completed initialization"
Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.780367237+08:00" level=info msg="Docker daemon" commit="88a4867/1.12.6" graphdriver=d...ion=1.12.
Aug :: node3 dockerd-current[]: time="2017-08-14T14:34:05.790544331+08:00" level=info msg="API listen on /var/run/docker.sock"
Aug :: node3 systemd[]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@node3 ~]#

3.查看版本

[root@node3 ~]# docker -version
Client:
Version: 1.12.
API version: 1.24
Package version: docker-1.12.-.git88a4867.el7.centos.x86_64
Go version: go1.7.4
Git commit: 88a4867/1.12.
Built: Mon Jul ::
OS/Arch: linux/amd64 Server:
Version: 1.12.
API version: 1.24
Package version: docker-1.12.-.git88a4867.el7.centos.x86_64
Go version: go1.7.4
Git commit: 88a4867/1.12.
Built: Mon Jul ::
OS/Arch: linux/amd64
[root@node3 ~]#

4.查看docker信息

[root@node3 ~]# docker info
Containers:
Running:
Paused:
Stopped:
Images:
Server Version: 1.12.
Storage Driver: devicemapper
Pool Name: docker-:--pool
Pool Blocksize: 65.54 kB
Base Device Size: 10.74 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 11.8 MB
Data Space Total: 107.4 GB
Data Space Available: 23.1 GB
Metadata Space Used: 581.6 kB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.147 GB
Thin Pool Minimum Free Space: 10.74 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count:
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.-RHEL7 (--)
Logging Driver: journald
Cgroup Driver: systemd
Plugins:
Volume: local
Network: null overlay host bridge
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Security Options: seccomp selinux
Kernel Version: 3.10.-.el7.x86_64
Operating System: CentOS Linux (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks:
CPUs:
Total Memory: 125.8 GiB
Name: node3
ID: VGL7:LAHR:ETDZ:M7A7:AGJG:HHLV:H4AR:3DY4:3DEA:ZHK4:4DI6:UUZG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
127.0.0.0/
Registries: docker.io (secure)
[root@node3 ~]#

5.开机自启动

$ sudo chkconfig docker on

三、卸载docker

1.列出已安装的包

$ yum list installed | grep docker
yum list installed | grep docker
docker-engine.x86_64 1.7.-.el7 @/docker-engine-1.7.-.el7.x86_64.rpm

2.删除安装包

$ sudo yum -y remove docker-engine.x86_64

3.删除镜像/容器等

$ rm -rf /var/lib/docker

四、安装docker镜像

1.docker镜像地址

官方:https://hub.docker.com/

国内网易:https://c.163.com/hub#/m/home/

2.安装centos镜像

以官方地址为例,打开网址,首页搜索centos,点击第一个,因为star最多嘛

复制右上角的命令到命令行执行

[root@ichz ~]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
7dc0dca2b151: Pull complete
Digest: sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa5322
Status: Downloaded newer image for docker.io/centos:latest
[root@ichz ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 49f7960eb7e4 days ago MB

好了,centos镜像就安装好了。

参考文章

https://blog.csdn.net/chengyuqiang/article/details/78886986

https://blog.csdn.net/a527219336/article/details/50800181

docker教程之从一头雾水到不一头雾水(1)的更多相关文章

  1. docker教程之从一头雾水到不一头雾水(2)

    书接上文:docker教程之从一头雾水到不一头雾水(1) 运行镜像 先查看下本地有哪些镜像 [root@ichz ~]# docker images REPOSITORY TAG IMAGE ID C ...

  2. Docker教程:docker machine的配置和命令

    http://blog.csdn.net/pipisorry/article/details/50921335 安装virtualbox 如果要使用virtualbox,首先要安装virtualbox ...

  3. Docker教程:dokcer machine的概念和安装

    http://blog.csdn.net/pipisorry/article/details/50920982 Docker machine介绍 做为Docker容器集群管理三剑客之一的Docker ...

  4. Docker教程:使用docker配置python开发环境

    http://blog.csdn.net/pipisorry/article/details/50808034 Docker的安装和配置 [Docker教程:docker的安装] [Docker教程: ...

  5. Docker教程:docker的概念及安装

    http://blog.csdn.net/pipisorry/article/details/50754385 Why docker 对于运维来说,Docker提供了一种可移植的标准化部署过程,使得规 ...

  6. 简明Docker教程

    Docker基础 这篇基础文章是方便用户在使用cSphere平台之前,了解docker基础知识. 针对已经有一定的Linux基础知识的用户. Docker是什么 Docker是一个改进的容器技术.具体 ...

  7. Docker 教程

    转自:http://www.runoob.com/docker/docker-tutorial.html Docker 教程

  8. Linux--CentOS 安装 Docker 教程

    本文主要介绍 CentOS 系统安装 Docker 的流程. 前提条件 OS 要求 CentOS7: The centos-extras repository must be enabled. Thi ...

  9. 小D课堂 - 新版本微服务springcloud+Docker教程_汇总

    小D课堂 - 新版本微服务springcloud+Docker教程_1_01课程简介 小D课堂 - 新版本微服务springcloud+Docker教程_1_02技术选型 小D课堂 - 新版本微服务s ...

  10. docker教程之从一头雾水到不一头雾水(3)

    本文主要是介绍Docker容器的相关内容 容器创建 我们已经知道,镜像是只读的,而基于镜像创建出来的容器是可读写的,所以,一般我们实际中,会经常使用对应镜像创建容器并且使用这些容器.同样,如果我们想要 ...

随机推荐

  1. App保持登录状态的常用方法(转)

    我们在使用App时,一次登录后App如果不主动退出登录或者清除数据,App会在很长一段时间内保持登录状态,或者让用户感觉到登录一次就不用每次都输入用户密码才能进行登录.银行.金融涉及到支付类的App一 ...

  2. HttpWebRequest 请求 Api 及 异常处理

    HttpWebRequest request = WebRequest.CreateHttp(url); request.Method = "post"; request.Head ...

  3. AtCoder - 3962 Sequence Growing Hard

    Problem Statement Find the number of the possible tuples of sequences (A0,A1,…,AN) that satisfy all ...

  4. 4.NFC前台调度系统

    使用目的:当前Activity能直接响应NFC标签,而不需要用户在choose所有能处理的Activity. 使用步骤: 第一步:在onCreate()方法中,创建一个PendingIntent对象 ...

  5. mysql系列-安装及服务启动

    一.window下的安装 详细见官网 https://dev.mysql.com/doc/refman/5.7/en/windows-installation.html 以 MySQL 5.1 免安装 ...

  6. 【Maven】1.使用myecplise配置自己的Maven配置,不使用默认的maven

    [好文章]参考地址: http://www.cnblogs.com/luotaoyeah/p/3764533.html ---------------------------------------- ...

  7. Javascript 内置值、typeof运算符、true/false判断

    一.内置值       true       false         null         undefined       NaN       Infinity   二.typeof运算结果 ...

  8. Go -- 在Go语言中使用JSON struct

    Encode 将一个对象编码成JSON数据,接受一个interface{}对象,返回[]byte和error: func Marshal(v interface{}) ([]byte, error) ...

  9. kubernetes--pod的生命周期管理

    下文基于kubernetes 1.5.2版本编写 lifecycle 概念 创建资源对象时,可以使用lifecycle来管理容器在运行前和关闭前的一些动作. lifecycle有两种回调函数: Pos ...

  10. WEB将本地项目添加到git

    前提下载好git bush1.找到对应的文件夹git init2.Windows下打开Git Bash$ ssh-keygen -t rsa -C "myaccount@example.co ...