Docker----基于CentOS系统安装Docker
作者:redrose2100   类别:    日期:2022-09-22 08:03:29    阅读:1506 次   消耗积分:0 分

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-engine

2 安装依赖

  1. sudo yum install -y yum-utils

3 配置repo源

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

4 安装docker engine

4.1 安装最新版docker engine

  1. sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

4.2 安装指定版本的docker engine

首先查看可以安装的版本

  1. yum list docker-ce --showduplicates | sort -r

比如执行结果如下:

比如安装 18.06.3.ce-3.el7 版本,则执行命令如下

  1. sudo yum install docker-ce-18.06.3.ce-3.el7 docker-ce-cli-18.06.3.ce-3.el7 containerd.io docker-compose-plugin

5 启动docker并设置开机自启动

  1. sudo systemctl start docker
  2. sudo systemctl enable docker

6 使用 hello-world 镜像验证安装结果

  1. sudo docker run hello-world

执行结果如下,表示docker已经安装成功

  1. [root@osssc-dev-01 ~]# sudo docker run hello-world
  2. Unable to find image 'hello-world:latest' locally
  3. latest: Pulling from library/hello-world
  4. 2db29710123e: Pull complete
  5. Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
  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/
  23. [root@osssc-dev-01 ~]#
始终坚持开源开放共享精神,同时感谢您的充电鼓励和支持!
版权所有,转载本站文章请注明出处:redrose2100, http://blog.redrose2100.com/article/380
个人成就
  • 博客总数: 613 
  • 阅读总量: 709417 
  • 2022年 : 371 篇 
  • 2023年 : 211 篇 
  • 2024年 : 31 篇 
  • 2025年 : 0 篇 
测试开发技术全栈公众号
DevOps技术交流微信群