利用官方脚本一键安装Docker

本文最后更新于:1 天前

我可以简单的理解docker为一个简便的应用封装器么?

前言

为了用Olaindex建一个分享网盘,我需要在服务器上配置php环境。我按照Olaindex的教程用Oneinstack安装了,结果是成功的失败了。
无奈只能把服务器回滚了。然后我想了想,不是说docker很方便么?于是就去搜了搜,结果还真找到了Olaindex的镜像。于是就安装了docker后试了试,还挺好用的。

真的是要吹爆docker。把需求的环境都封装了,剩下的就只有简单的配置了,怪不得这么多人用。

利用官方脚本安装

还是说一下我的环境

  • 系统: debian10
    一键安装真的是方便,导致这个文章的正文看起来没啥。
    1
    2
    curl -fsSL get.docker.com -o get-docker.sh
    sudo sh get-docker.sh
    这样就可以了。这样就安装完成了。
    安装完成之后验证是否安装成功。

启动Docker

1
2
sudo systemctl enable docker
sudo systemctl start docker

建立 docker 用户组

默认情况下,只有 root 用户和 docker 组的用户才可以访问 Docker。出于安全考虑,一般 Linux 系统上不会直接使用 root 用户。因此,更好地做法是将需要使用 docker 的用户加入 docker 用户组。

建立 docker 组:

1
sudo groupadd docker

将当前用户加入 docker 组:

1
sudo usermod -aG docker $USER

退出当前终端并重新登录,进行如下测试。

测试 Docker 是否安装正确

1
docker run hello-world
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: 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/

若能正常输出以上信息,则说明安装成功。

参考

Debian 安装 Docker CE
Install Docker Engine on Debian (这个是官网)


利用官方脚本一键安装Docker
https://www.yikakia.com/利用官方脚本一键安装docker/
作者
Yika
发布于
2020年4月11日
许可协议