千家信息网

如何安装docker和docker-compose

发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,小编给大家分享一下如何安装docker和docker-compose,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!想快速装
千家信息网最后更新 2026年11月03日如何安装docker和docker-compose

小编给大家分享一下如何安装docker和docker-compose,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

想快速装好docker和docker-compose ?那就随本文用一次复制粘贴来完成安装:

环境信息

  1. 操作系统:CentOS Linux release 7.7.1908 (Core,

  2. 操作账号:root

  3. Docker版本:当前最新版本:19.03.2

  4. docker-compose版本:当前最新版本:1.24.1

安装

执行以下命令(若非root账号,请自行添加sudo):

yum install -y yum-utils device-mapper-persistent-data lvm2 \&& yum-config-manager \    --add-repo \    https://download.docker.com/linux/centos/docker-ce.repo \&& yum install  -y docker-ce docker-ce-cli containerd.io \&& systemctl start docker \&& yum -y install epel-release \&& yum -y install python-pip \&& pip install --upgrade pip \&& pip install docker-compose

等待几分钟,即完成docker和docker-compose的安装

验证

  1. docker版本:

[root@centos7 ~]# docker versionClient: Docker Engine - Community Version:           19.03.2 API version:       1.40 Go version:        go1.12.8 Git commit:        6a30dfc Built:             Thu Aug 29 05:28:55 2019 OS/Arch:           linux/amd64 Experimental:      falseServer: Docker Engine - Community Engine:  Version:          19.03.2  API version:      1.40 (minimum version 1.12)  Go version:       go1.12.8  Git commit:       6a30dfc  Built:            Thu Aug 29 05:27:34 2019  OS/Arch:          linux/amd64  Experimental:     false containerd:  Version:          1.2.6  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb runc:  Version:          1.0.0-rc8  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f docker-init:  Version:          0.18.0  GitCommit:        fec3683
  1. docker-compose版本:

[root@centos7 ~]# docker-compose versiondocker-compose version 1.24.1, build 4667896docker-py version: 3.7.3CPython version: 2.7.5OpenSSL version: OpenSSL 1.0.2k-fips  26 Jan 2017
  1. 运行hello world:

[root@centos7 ~]# docker run --rm hello-worldUnable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-world1b930d010525: Pull complete Digest: sha256:b8ba256769a0ac28dd126d584e0a2011cd2877f3f76e093a7ae560f2a5301c00Status: Downloaded newer image for hello-world:latestHello 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 bashShare 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/

以上是"如何安装docker和docker-compose"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

版本 篇文章 内容 账号 操作系统 不怎么 信息 命令 大部分 更多 环境 知识 系统 行业 资讯 资讯频道 频道 装好 参考 学习 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 互联网科技工作委员会毛军 厦门中拓互联网络科技有限公司 互联网科技英文 世界互联网领先科技成果 长亮科技互联网金融 互联网科技视频素材 科技伦理 互联网公司 哈尔滨新华互联网科技 广州恒生互联网科技有限 武汉健翔互联网络科技有限公司 互联网科技与大数据专业 阿里互联网科技企业 伊宁互联网科技做什么的 为客找房互联网科技公司怎么样 伍佰万互联网科技怎么赚钱 张召忠谈中国互联网科技 互联网风格科技公司名称 下一代互联网重大应用科技园 广西科技产业互联网是什么 陕西彩京云互联网科技有限公司 伟宏互联网科技 中关村互联网 科技集团 中国互联网科技工作委员会毛军 互联网科技公司税收优惠 奇酷互联网科技 奇酷互联网络科技公司 互联网科技大会 怎样加入科技互联网 广东工业互联网大赛深圳学泰科技 互联网领先科技成果宣传视频
0