Linux_Docker

centos 下安装 docker

2021-08-21  本文已影响0人  shengjk1

docker 是什么

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

why we nedd docker

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

docker 安装

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

  1. 如果已经安装过老版本 docker 了,先卸载
   sudo yum remove docker \
                     docker-client \
                     docker-client-latest \
                     docker-common \
                     docker-latest \
                     docker-latest-logrotate \
                     docker-logrotate \
                     docker-engine
  1. 安装 yum 的类库
     sudo yum install -y yum-utils
  1. 设置 docker 的国内源
      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/

  1. 设置 cache
    yum makecache fast

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

  1. 安装
  yum -y install docker-ce
  1. 启动
        service docker start
  1. 验证
  docker pull hello-world   下载 hello world 镜像
 
  docker run hello-world     运行
[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/

表示运行成功

上一篇下一篇

猜你喜欢

热点阅读