写点什么

一行命令安装 docker 和 docker-compose(CentOS7)

作者:程序员欣宸
  • 2022-10-25
    广东
  • 本文字数:1532 字

    阅读完需:约 5 分钟

一行命令安装docker和docker-compose(CentOS7)

欢迎访问我的 GitHub

这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos


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

环境信息

  1. 操作系统: CentOS Linux release 7.7.1908

  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 的安装

验证

  • 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:      false
Server: 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
复制代码


  • 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
复制代码


  • 运行 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: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. (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/
复制代码


  • 操作完成,希望这一次复制粘贴能助您快速开启 docker 之旅。

欢迎关注 InfoQ:程序员欣宸

学习路上,你不孤单,欣宸原创一路相伴...


发布于: 2022-10-25阅读数: 18
用户头像

搜索"程序员欣宸",一起畅游Java宇宙 2018-04-19 加入

前腾讯、前阿里员工,从事Java后台工作,对Docker和Kubernetes充满热爱,所有文章均为作者原创,个人Github:https://github.com/zq2599/blog_demos

评论

发布
暂无评论
一行命令安装docker和docker-compose(CentOS7)_Docker_程序员欣宸_InfoQ写作社区