docker安装

简介: docker安装

Docker支持运行在以下CentOS版本:


CentOS 7.X


安装在二进制兼容的EL7版本如 Scientific Linux也是可能成功的,但是Docker

没有测试过并且不官方支持。


此文带你通过使用Docker管理的发行包和安装机制来安装。使用这些报能确保你使用最新的Docker版本。


如果你希望使用CentOS管理的包,请阅读你的CentOS文档。


要求


不过你的系统版本是多少,Docker都要求64位。并且当CentOS7时你的内核必须不小于3.10。


检查当前内核版本:


uname -r


3.10.0-229.el7.x86_64


建议将系统升级到最新。


安装


有两种方式可安装Docker Engine。脚本安装和yum安装。


脚本安装


1.使用root权限登陆系统。


2.更新系统包到最新。


# yum -y update


3.执行Docker安装脚本


# curl -sSL https://get.docker.com/ | sh


# yum install -y docker-selinux


这个脚本会添加docker.repo 配置并安装Docker。


4.启动Docker


# systemctl start docker.service


5.验证docker已经正常安装


# docker run hello-world


yum安装


1.使用root权限登陆系统。


2.更新系统包到最新。


# yum -y update


3.添加yum仓库


# cat >/etc/yum.repos.d/docker.repo <<-EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF


4.安装Docker包


# yum install -y docker-engine
yum install -y docker-selinux


yum list installed | grep docker
docker-engine.x86_64             1.8.1-1.el7.centos                    @dockerrepo
docker-selinux.x86_64            1.7.1-108.el7.centos                  @extras


这里有个非常坑的情况,官方文档没有提到docker-selinux的安装,笔者在使用VirtualBox,配置一个桥接,一个Host-Only的网卡时,只安装docker-engine启动会报错,需要在安装docker-selinux方可。


可以看github上的两个issues,1.8.0: Systemd can’t start docker on Centos 7.1 #15498,Docker start times out if firewalld is started #13019。


5.启动Docker


# systemctl start docker.service


6.验证docker已经正常安装


# docker run hello-world


Unable to find image ‘hello-world:latest’ locally


latest: Pulling from library/hello-world


535020c3e8ad: Pull complete


af340544ed62: Already exists


library/hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.

Digest: sha256:d5fbd996e6562438f7ea5389d7da867fe58e04d581810e230df4cc073271ea52

Status: Downloaded newer image for hello-world:latest


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.
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 Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/userguide/
目录
相关文章
|
2天前
|
前端开发 jenkins 持续交付
新的centos7.9安装docker版本的jenkins2.436.1最新版本-前端项目发布(五)
新的centos7.9安装docker版本的jenkins2.436.1最新版本-前端项目发布(五)
19 1
|
2天前
|
jenkins 网络安全 持续交付
新的centos7.9安装docker版本的jenkins2.436.1最新版本-后端项目发布(四)
新的centos7.9安装docker版本的jenkins2.436.1最新版本-后端项目发布(四)
14 3
|
2天前
|
网络协议 Linux Docker
在centos7下通过docker 安装onlyoffice
在centos7下通过docker 安装onlyoffice
23 0
|
15小时前
|
Ubuntu Linux Docker
window10下安装ubuntu系统以及docker使用
window10下安装ubuntu系统以及docker使用
|
2天前
|
并行计算 Ubuntu Docker
Docker环境Ubuntu20.04安装Python3.10版本
Docker环境Ubuntu20.04安装Python3.10版本
14 0
|
2天前
|
Ubuntu Docker 容器
Ubuntu 22.04.3 LTS_安装Docker
Ubuntu 22.04.3 LTS_安装Docker
34 1
|
2天前
|
应用服务中间件 PHP nginx
安装基于docker的php运行环境
安装基于docker的php运行环境
10 0
|
2天前
|
并行计算 Shell Docker
【环境配置】Ubuntu16.04安装nvidia-docker
【环境配置】Ubuntu16.04安装nvidia-docker
18 2
|
2天前
|
Kubernetes Docker 容器
Docker 安装 Portainer
Portainer Community Edition是一个针对容器化应用程序的轻量级服务交付平台,可用于管理 Docker、Swarm、Kubernetes 和 ACI 环境。它的设计理念是部署和使用都简单,该应用程序允许您通过“智能”GUI 和/或广泛的 API 管理所有编排器资源。
41 3
|
2天前
|
Java 开发工具 git
新的centos7.9安装docker版本的jenkins2.436.1最新版本-项目发布(三)
新的centos7.9安装docker版本的jenkins2.436.1最新版本-项目发布(三)
12 4