本文内容摘自官网:https://docs.docker.com/engine/installation/linux/centos/#/create-a-docker-group

注:本文是介绍Linux 上的分布式版本CentOs上安装.

一、安装前的准备工作

Docker 需要安装在64位系统的CentOS上,而且linux内核至少在3.10版本以上,这个版本的内核在CenOS7上运行. 所以只要安装一个CenOS7  64位的系统就可以了.作为学习,大家只需安装个虚拟机就OK.
可以通过uname  -r 来查看linux内核版本.
[root@localhost ~]# uname -r
3.10.0-327.el7.x86_64

最后,建议你全面更新你的系统. 请记住,你已经完全修复任何潜在的内核bug.

二、安装Docker

有两种方式来安装Docker,这里只介绍其中的一种,通过yum来安装Docker.
1、用一个用户登录你的机器,这个用户必须拥有sudo或root权限.
2、为了确保你的yum包是最新的,用下面脚本做下更新.
[root@localhost ~]# sudo yum update

3、加入yum repo

$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

4、安装Docker包

$ sudo yum install docker-engine

5、启动Docker守护进程

$ sudo service docker start

6、通过运行容器中的一个测试image,来验证你的Docker安装正确.

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world
a8219747be10: Pull complete
91c95931e552: Already exists
hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd1.7.1cf5daeb82aab55838d
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(Assuming it was not already locally available.)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal. To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash For more examples and ideas, visit:
http://docs.docker.com/userguide/

至此,Docker就已安装好了.

三、自动启动Docker

若要保证,你开机时,自动启动Docker,可以执行如下的命令:
[root@localhost ~]# sudo chkconfig docker on
Note: Forwarding request to 'systemctl enable docker.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

四、Docker 卸载

1、列出你已安装的Docker package.
[root@localhost ~]# yum list installed | grep docker
docker-engine.x86_64 1.12.1-1.el7.centos @dockerrepo
docker-engine-selinux.noarch 1.12.1-1.el7.centos @dockerrepo

2 、移除这个package

$ sudo yum -y remove docker-engine.x86_64

这个命令没有移除images、containers、volumes或者你主机上用户创建的配置文件.

[root@localhost ~]# ll /var/lib/docker/
total 4
drwx------. 5 root root 4096 8月 23 10:03 containers
drwx------. 5 root root 50 8月 23 09:30 devicemapper
drwx------. 3 root root 25 8月 23 09:30 image
drwxr-x---. 3 root root 18 8月 23 09:30 network
drwx------. 2 root root 6 8月 23 09:30 swarm
drwx------. 2 root root 6 8月 23 09:30 tmp
drwx------. 2 root root 6 8月 23 09:30 trust
drwx------. 2 root root 24 8月 23 09:30 volumes
3、要删除所有的images、containers、volumes,运行如下命令.
$ rm -rf /var/lib/docker

4、查找和删除任何用户创建的配置文件.

Docker学习笔记1:CentOS7 下安装Docker的更多相关文章

  1. 学习笔记(1)centos7 下安装nginx

    学习笔记(1)centos7 下安装nginx 这里我是通过来自nginx.org的nginx软件包进行安装的. 1.首先为centos设置添加nginx的yum存储库 1.通过vi命令创建一个rep ...

  2. docker学习之路-centos下安装docker

    前言 我要在云服务器上做一个asp.net core的webapi应用,使用docker来部署应用,中间用到的任何组件包括nginx和sqlserver 2017都是用docker来装载运行,所以,这 ...

  3. 学习笔记(3)centos7 下安装RabbitMQ

    centos7 安装RabbitMQ 安装erlang 因为RabbitMQ由ERLANG实现,所以需要先安装erlang.可以从https://www.erlang-solutions.com/re ...

  4. 学习笔记(2)centos7 下安装mysql

    centos7安装mysql 本文通过yum方式安装mysql 1.添加mysql yum 仓库 去mysql开发者中心(http://dev.mysql.com/downloads/repo/yum ...

  5. centos7下安装docker与镜像加速

    1.背景 centos7下安装docker 2.安装 第一步:检查是否为centos7版本 第二步:依赖环境安装 执行如下两个命令: yum -y install gcc yum -y install ...

  6. docker(一) Centos7下安装docker

    docker(一) Centos7下安装dockerdocker(二) windows10下安装dockerdocker(三) 镜像和容器常用命令 docker(四) 使用Dockerfile构建镜像 ...

  7. CentOS7下安装docker(Docker系列1)

    CentOS7下安装docker 系统要求 为了安装docker,需要准备 64-bit的CentOS 7 删除非官方的Docker包 yum的仓库中有一个很旧的Docker包, 现在Docker官方 ...

  8. centos7 下安装docker报错:You could try using...

    搞了台VPS,想要装docker,发现死活装不上,各种报错.之前系统是centos6,发现官方现在已经不支持centos6了,遂升级到centos7,然后还是出现下面这个错误. Error: Pack ...

  9. Centos7 下安装 Docker

    一.简介 Docker是一个开源的应用容器引擎:是一个轻量级容器技术:Docker支持将软件编译成一个镜像:然后在镜像中各种软件做好配置,将镜像发布出去,其他使用者可以直接使用这个镜像:运行中的这个镜 ...

随机推荐

  1. SVN上传项目步骤

    1.svn上传项目  首先选中父工程 ,右键选中Team的share project 2.share完再选中SVN 3.选中项目  一个一个share project 4.

  2. VueJs 源码解析 (四) initRender.Js

    vueJs 源码解析 (四) initRender.Js 在之前的文章中提到了 vuejs 源码中的 架构部分,以及 谈论到了 vue 源码三要素 vm.compiler.watcher 这三要素,那 ...

  3. [LeetCode] Flood Fill 洪水填充

    An image is represented by a 2-D array of integers, each integer representing the pixel value of the ...

  4. Mysql之视图的操作

    视图的操作: 1.视图的创建: create view view_name as 查询语句; 2.视图的查看: show tables;// 显示所有的表和视图 show create view vi ...

  5. [USACO 13DEC]Vacation Planning(gold)

    Description Air Bovinia operates flights connecting the N farms that the cows live on (1 <= N < ...

  6. [NOI 2011]道路修建

    Description 在 W 星球上有 n 个国家.为了各自国家的经济发展,他们决定在各个国家 之间建设双向道路使得国家之间连通.但是每个国家的国王都很吝啬,他们只愿 意修建恰好 n – 1条双向道 ...

  7. codeforces 868B Race Against Time

    Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a si ...

  8. [SDOI2014]数表

    题目描述 有一张N*m的数表,其第i行第j列(1 < =i < =礼,1 < =j < =m)的数值为能同时整除i和j的所有自然数之和.给定a,计算数表中不大于a的数之和. 输 ...

  9. hihocoder #1142 : 三分·三分求极值

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 这一次我们就简单一点了,题目在此: 在直角坐标系中有一条抛物线y=ax^2+bx+c和一个点P(x,y),求点P到抛物线的 ...

  10. python raise和assert的区别

    python中raise和assert的区别 一.使用raise抛出异常 python可以自动触发异常,raise(内置函数)的定义为显示的抛出异常,用户可以使用raise进行判断,显式的引发异常,r ...