首页 > 其他 > 详细

Docker-安装

时间:2020-06-05 09:45:14      阅读:37      评论:0      收藏:0      [点我收藏+]

docker安装要求

  • Docker CE支持64位版本CentOS 7
  • 内核 >= 3.10

docker使用注意点

  • 只有rootdocker组的用户才可以访问Docker引擎的Unix socket
  • 安全考虑,一般用普通用户加入docker用户组使用"usermod -G docker user"
  • 确认/etc/group是否有docker组,没有则创建"groupadd docker"

在有外网的情况下使用yum安装

卸载旧版本

]$ sudo rpm -qa docker* #先查看是否安装,然后再卸载
]$ sudo yum remove docker #也可以直接运行此命令卸载
docker-client docker-client-latest docker-common docker-latest docker-latest-logrotatte docker-logrotate docker-selinux docker-engine-selinu dokcer-engine

安装依赖包

]$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

添加docker的yum源

]$ sudo yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
]$ sudo sed -i ‘s/download.docker.com/mirrors.ustc.edu.cn\/docker-ce/g‘ /etc/yum.repos.d/docker-ce.repo #使用国内源

安装docker-ce

]$ sudo yum makecache fast
]$ sudo yum install docker-ce -y

启动docker-ce

]$ sudo systemctl enable docker
]$ sudo systemctl start docker

在有外网的情况下使用脚本自动安装

在测试或开发环境中Docker官方为了简化安装流程,提供了一套便捷的安装脚本,CentOS系统上可以使用这套脚本安装,另外可以通过--mirror选项使用国内源进行安装

下载脚本安装

]$ curl -fsSL get.docker.com -o get-docker.sh
]$ sudo sh get-docker.sh --mirror Aliyun

启动docker-ce

]$ sudo systemctl enable docker
]$ sudo systemctl start docker

测试docker是否安装正确

]$ docker run hello-world
Unable to find image ‘hello-world:latest‘ locally
latest: Pulling from library/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/

输出以上信息说明安装成功

镜像加速

加速器地址

编辑/etc/docker/daemon.json文件(若不存在需新建)

echo -e "{\n \"registry-mirrors\": [ \"https://hub-mirror.c.163.com\",\"https://mirror.baidubce.com\"] \n}" > /etc/docker/daemon.json

检查加速器是否生效

]$ docker info
...省略
Registry Mirrors:
  https://hub-mirror.c.163.com/
  https://mirror.baidubce.com/
 ...省略
 有上面信息即配置成功

Docker-安装

原文:https://www.cnblogs.com/wanwz/p/12785072.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!