Centos7Docker环境搭建

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7Docker环境搭建相关的知识,希望对你有一定的参考价值。

1 移除旧的docker软件

[[email protected] ~]yum remove docker*

2 添加epel源以及docker源

[[email protected] ~]wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo ##添加epel的yum源
[[email protected] ~]yum-config-manager --add-repo  https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo  ##添加docker的yum源

3 使用yum安装docker

[[email protected] ~]yum -y install docker-ce

4 创建docker组(如果已经存在则无需创建)并且将当前用户的附属组设置为docker(因为默认情况下,docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑,一般 Linux 系统上不会直接使用 root 用户。因此,更好地做法是将需要使用 docker 的用户加入 docker 用户组)

[[email protected] ~]groupadd docker
[[email protected] ~]usermod -aG docker $USER

5 测试docker是否安装成功

[[email protected] ~]docker run hello-world

出现以下字样则证明安装成功!
Unable to find image ‘hello-world:latest‘ locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctl

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://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

以上是关于Centos7Docker环境搭建的主要内容,如果未能解决你的问题,请参考以下文章

开源仓库Harbor搭建及配置过程

docker私人仓库搭建(docker方式)

node 环境下简单web服务器搭建代码

docker私人仓库

docker-compose搭建Redis哨兵模式

kafka的Docker镜像使用说明(wurstmeister/kafka)