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/
相关文章
|
6月前
|
关系型数据库 应用服务中间件 nginx
Docker一键安装中间件(RocketMq、Nginx、MySql、Minio、Jenkins、Redis)
本系列脚本提供RocketMQ、Nginx、MySQL、MinIO、Jenkins和Redis的Docker一键安装与配置方案,适用于快速部署微服务基础环境。
|
4月前
|
关系型数据库 数据库 PostgreSQL
docker 安装 Postgres 17.6
本文介绍如何通过Docker安装和配置PostgreSQL 17.6。内容包括拉取镜像、导出配置文件、运行容器并挂载数据与配置文件目录,以及进入容器使用psql操作数据库的完整步骤,便于持久化管理和自定义配置。
531 3
docker 安装 Postgres 17.6
|
3月前
|
NoSQL 算法 Redis
【Docker】(3)学习Docker中 镜像与容器数据卷、映射关系!手把手带你安装 MySql主从同步 和 Redis三主三从集群!并且进行主从切换与扩容操作,还有分析 哈希分区 等知识点!
Union文件系统(UnionFS)是一种**分层、轻量级并且高性能的文件系统**,它支持对文件系统的修改作为一次提交来一层层的叠加,同时可以将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtual filesystem) Union 文件系统是 Docker 镜像的基础。 镜像可以通过分层来进行继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。
566 5
|
3月前
|
Java Linux 虚拟化
【Docker】(1)Docker的概述与架构,手把手带你安装Docker,云原生路上不可缺少的一门技术!
1. Docker简介 1.1 Docker是什么 为什么docker会出现? 假定您在开发一款平台项目,您的开发环境具有特定的配置。其他开发人员身处的环境配置也各有不同。 您正在开发的应用依赖于您当前的配置且还要依赖于某些配置文件。 您的企业还拥有标准化的测试和生产环境,且具有自身的配置和一系列支持文件。 **要求:**希望尽可能多在本地模拟这些环境而不产生重新创建服务器环境的开销 问题: 要如何确保应用能够在这些环境中运行和通过质量检测? 在部署过程中不出现令人头疼的版本、配置问题 无需重新编写代码和进行故障修复
403 2
|
9月前
|
存储 安全 C++
Odoo 安装方式选择:源码安装 vs Docker
Odoo部署常采用源码编译或Docker容器化,但分别面临依赖复杂、版本风险和服务化难题,以及镜像臃肿和扩展受限的问题。Websoft9提出混合方案,融合两者优势:通过智能环境适配、三阶段部署流程(环境预检、混合模式选择、持久化配置)及声明式YAML配置,实现高效、灵活的双模运行时。此方案显著降低依赖冲突解决时间(从83分钟至0),生产环境构建耗时缩短至8分钟,并达100% CVE漏洞修复率,适合ERP定制开发与规模化部署的企业需求。
|
7月前
|
存储 NoSQL MongoDB
Docker中安装MongoDB并配置数据、日志、配置文件持久化。
现在,你有了一个运行在Docker中的MongoDB,它拥有自己的小空间,对高楼大厦的崩塌视而不见(会话丢失和数据不持久化的问题)。这个MongoDB的数据、日志、配置文件都会妥妥地保存在你为它精心准备的地方,天旋地转,它也不会失去一丁点儿宝贵的记忆(即使在容器重启后)。
868 4
|
6月前
|
Linux Docker Windows
windows docker安装报错适用于 Linux 的 Windows 子系统必须更新到最新版本才能继续。可通过运行 “wsl.exe --update” 进行更新。
适用于 Linux 的 Windows 子系统需更新至最新版本(如 wsl.2.4.11.0.x64.msi)以解决 2025 年 Windows 更新后可能出现的兼容性问题。用户可通过运行 “wsl.exe --update” 或访问提供的链接下载升级包进行更新。
2424 0