阿里云服务器centos7 安装docker

版权声明:原创文章欢迎转载,不过要记得加出处哦 https://blog.csdn.net/wljk506/article/details/88566915

推荐用阿里云的容器服务

环境检测更新

环境检测

Docker 要求 CentOS 系统的内核版本高于 3.10

uname -r

#输出
3.10.0-862.14.4.el7.x86_64

更新

yum -y update

创建用户及用户组

useradd docker

设置用户密码

passwd docker

随后要输入2次密码

安装docker

执行自动安装命令

curl -fsSL https://get.docker.com/ | sh

执行

usermod -aG docker docker

启动

设置启动和开机启动

systemctl start docker
systemctl enable docker

切换到docker用户下

方式一

su docker

方式二

退出root用户,使用docker用户登录

下载和运行hello-world镜像容器

要在 docker 用户下操作,不能在 root 用户下操作
下载镜像

docker pull hello-world

运行容器

docker run hello-world

输出

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/

FAQ

猜你喜欢

转载自blog.csdn.net/wljk506/article/details/88566915