前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >centos 下安装 docker

centos 下安装 docker

作者头像
shengjk1
发布2021-08-24 10:34:46
发布2021-08-24 10:34:46
43900
代码可运行
举报
文章被收录于专栏:码字搬砖码字搬砖
运行总次数:0
代码可运行

docker 是什么

docker是容器化平台,提供打包,部署和运行应用

why we nedd docker

可以实现一次配置到处运行,避免了环境类库等各种问题,可以大大提高了交付、开发效率

docker 安装

以 centos 为例。目前 docker 仅仅支持 centos7/8

  1. 如果已经安装过老版本 docker 了,先卸载
代码语言:javascript
代码运行次数:0
复制
   sudo yum remove docker \
                     docker-client \
                     docker-client-latest \
                     docker-common \
                     docker-latest \
                     docker-latest-logrotate \
                     docker-logrotate \
                     docker-engine

2. 安装 yum 的类库

代码语言:javascript
代码运行次数:0
复制
     sudo yum install -y yum-utils

3. 设置 docker 的国内源

代码语言:javascript
代码运行次数:0
复制
      yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

其中 docker-ce 为社区版对于个人和大多数的企业 ce版已经够用了,两者之间具体的区别可以参考 https://boxboat.com/2018/12/07/docker-ce-vs-docker-ee/

4. 设置 cache

代码语言:javascript
代码运行次数:0
复制
    yum makecache fast

主要的一个目的将服务器上的软件包信息 现在本地缓存,以提高 搜索 安装软件的速度

5. 安装

代码语言:javascript
代码运行次数:0
复制
  yum -y install docker-ce

6. 启动

代码语言:javascript
代码运行次数:0
复制
        service docker start

7. 验证

代码语言:javascript
代码运行次数:0
复制
  docker pull hello-world   下载 hello world 镜像
 
  docker run hello-world     运行
代码语言:javascript
代码运行次数:0
复制
[root@192 ~]# docker run hello-world

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.
    (amd64)
 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

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

表示运行成功

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/08/21 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • docker 是什么
  • why we nedd docker
  • docker 安装
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档