【centos7】安装docker

雨点打透心脏的1/2处 2022-04-01 11:48 238阅读 0赞

下面是安装docker-communtiy版本的方法。

参考:
https://docs.docker.com/install/linux/docker-ce/centos/#upgrade-docker-after-using-the-convenience-script

1. 清除可能存在的老版本

  1. $ sudo yum remove docker \
  2. docker-client \
  3. docker-client-latest \
  4. docker-common \
  5. docker-latest \
  6. docker-latest-logrotate \
  7. docker-logrotate \
  8. docker-selinux \
  9. docker-engine-selinux \
  10. docker-engine

2. 下载rpm文件

  1. containerd.io-1.2.0-3.el7.x86_64.rpm
  2. docker-ce-cli-18.09.0-3.el7.x86_64.rpm
  3. docker-ce-18.09.0-3.el7.x86_64.rpm

下载页面: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

分别对如上文件进行安装

  1. sudo yum install containerd.io-1.2.0-3.el7.x86_64.rpm
  2. sudo yum install docker-ce-cli-18.09.0-3.el7.x86_64.rpm
  3. sudo yum install docker-ce-18.09.0-3.el7.x86_64.rpm

3. 设置docker deamon自启动

  1. [root@localhost ~]# systemctl enable docker
  2. Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

4. 镜像加速

国内连接Docker hub网络情况不佳,我们可以考虑国内提供加速服务的公司,目前有阿里云和daoCloud的加速,下面已daocloud的镜像加速为例。

  1. curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

该脚本可以将 —registry-mirror 加入到你的 Docker 配置文件 /etc/docker/daemon.json 中。适用于 Ubuntu14.04、Debian、CentOS6 、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1,其他版本可能有细微不同。更多详情请访问文档。

5. 启动Docker

  1. systemctl start docker

6. 示例

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

发表评论

表情:
评论列表 (有 0 条评论,238人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Centos 7 Docker安装

    > 如果我的博客能够帮到大家能够点个赞,关注一下,以后还会更新更过JavaWeb的高级技术,大家的支持就是我继续更新的动力。谢谢。 > Docker 是一个开源的应用容器引擎

    相关 CentOS7安装Docker

    一、Docker简介           Docker 是一个[开源][Link 1]的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到