标签:docker环境搭建
1 移除旧的docker软件[root@localhost ~]yum remove docker*
2 添加epel源以及docker源
[root@localhost ~]wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo ##添加epel的yum源
[root@localhost ~]yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo ##添加docker的yum源
3 使用yum安装docker
[root@localhost ~]yum -y install docker-ce
4 创建docker组(如果已经存在则无需创建)并且将当前用户的附属组设置为docker(因为默认情况下,docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑,一般 Linux 系统上不会直接使用 root 用户。因此,更好地做法是将需要使用 docker 的用户加入 docker 用户组)
[root@localhost ~]groupadd docker
[root@localhost ~]usermod -aG docker $USER
5 测试docker是否安装成功
[root@localhost ~]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/
标签:docker环境搭建
原文地址:http://blog.51cto.com/kaikai0720/2125579