Docker安装步骤

  在学习springcloud的消息总线时,需要安装rabbitmq,因为rabbitmq是用erlang开发的,所以安装rabbitmq又需要先安装erlang,总之安装过程中遇到各种坑,然而最终还是没有安装成功,最后就打算放弃普通的安装方式,用基于docker的方式来安装,这也就是今天的主题:docker的安装步骤,在docker安装的过程中,同样也是困难重重,一开始我是在32位的Centos6.5下安装的,结果遇到各种问题,后来才发现docker是不支持32位操作系统的,然后又重新在虚拟机上装了64位的Centos7,下面记录一下我的安装步骤:

一、准备环境:64位Centos7(注意:这里的系统一定要是64位的,docker不支持32位操作系统,且Centos6和Centos7安装命令是不同的,这里我是基于Centos7进行安装)

  1.查看centos系统的版本:

1 [root@localhost ~]# cat /etc/redhat-release
2 CentOS Linux release 7.5.1804 (Core) 
3 [root@localhost ~]#

  2.查看内核版本:

1 [root@localhost ~]# 
2 [root@localhost ~]# uname  -a
3 Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
4 [root@localhost ~]# 

二、安装步骤:

  1.安装所需的软件包。

1 sudo yum install -y yum-utils device-mapper-persistent-data lvm2

  2.添加Docker软件包源 。

1 sudo yum-config-manager \
2      --add-repo \
3      https://download.docker.com/linux/centos/docker-ce.repo

  以上命令会在/etc/yum.repos.d/ 目录下生成docker-ce.repo文件

  3.(可选)启用 edge 和 testing 镜像仓库。这些镜像仓库包含在上述 docker.repo 文件中,但默认情况下处于禁用状态。您可以将它们与 stable 镜像仓库一起启用。

1 sudo yum-config-manager --enable docker-ce-edge
2 sudo yum-config-manager --enable docker-ce-testing

  4.更新 yum 软件包索引。

1 sudo yum makecache fast

  5.安装 Docker CE。

1 sudo yum install docker-ce

  6.启动 Docker。

1 sudo systemctl start docker

  7.验证是否正确安装了 docker,方法是运行 hello-world 镜像。

1 sudo docker run hello-world
 1 [root@localhost ~]# docker run hello-world
 2 Unable to find image 'hello-world:latest' locally
 3 latest: Pulling from library/hello-world
 4 1b930d010525: Pull complete 
 5 Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
 6 Status: Downloaded newer image for hello-world:latest
 7 
 8 Hello from Docker!
 9 This message shows that your installation appears to be working correctly.
10 
11 To generate this message, Docker took the following steps:
12  1. The Docker client contacted the Docker daemon.
13  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
14     (amd64)
15  3. The Docker daemon created a new container from that image which runs the
16     executable that produces the output you are currently reading.
17  4. The Docker daemon streamed that output to the Docker client, which sent it
18     to your terminal.
19 
20 To try something more ambitious, you can run an Ubuntu container with:
21  $ docker run -it ubuntu bash
22 
23 Share images, automate workflows, and more with a free Docker ID:
24  https://hub.docker.com/
25 
26 For more examples and ideas, visit:
27  https://docs.docker.com/get-started/

出现如上代码说明我们的docker已经安装好了,让我们一起进入我们的docker之旅吧!

(注意:如果是root用户的话以上的所有命令前面不用加sudo,如果你的普通用户不可以执行sudo,可以切换到root用户执行上面命令,或者切换到root用户 vi /etc/sudoers ,

假如你的用户名为zhangsan,在 root   ALL=(ALL)    ALL后面加一行 zhangsan  ALL=(ALL)    ALL,这样再切换到zhangsan用户下就可以执行sudo命令了)。

1 [root@localhost fanjf]# vi /etc/sudoers
2 ## Sudoers allows particular users to run various commands as
3 ## the root user, without needing the root password.
4 root ALL=(ALL)  ALL
5 zhangsan  ALL=(ALL)  ALL
6 #.......
7 #.......
8 #.......

 

转载于:https://www.cnblogs.com/fanjianfei/p/10722095.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值