使用官方脚本一键安装docker|安装docker-compose

本文最后更新于 6 个月前,文中所描述的信息可能已发生改变。

安装docker

docker官方提供了傻瓜式安装脚本,为你做好所有工作,免去了手动安装的繁琐。

本文实测系统环境:debian11

执行以下命令

2023-03-07更新2023-03-07更新

不知道从什么时候开始官方脚本已经默认也安装了 docker compose,不需要后面的手动安装了

注意是 docker compose 而不是 docker-compose. 执行命令时候也没有这个杠

shell
curl -fsSL https://get.docker.com | bash -s docker
curl -fsSL https://get.docker.com | bash -s docker

可在此命令后附带--mirror参数设置镜像源,以提高国内服务器下载docker的速度

若登录linux的用户不是root,则需要docker的用户加入 docker 用户组。 参考以下命令。

bash
sudo groupadd docker # 建立docker用户组
sudo usermod -aG docker $USER #将当前用户加入 docker 组
sudo groupadd docker # 建立docker用户组
sudo usermod -aG docker $USER #将当前用户加入 docker 组

done

重新登录ssh终端,可执行以下命令测试是否正确安装docker docker run hello-world 正确安装的输出信息如下:

bash
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: xxxxxxxxxxxxxxxx
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/
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: xxxxxxxxxxxxxxxx
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/

安装docker-compose

执行以下命令

shell
curl -L https://github.com/docker/compose/releases/download/v2.14.0/docker-compose-linux-`uname -m` > ./docker-compose
curl -L https://github.com/docker/compose/releases/download/v2.14.0/docker-compose-linux-`uname -m` > ./docker-compose

注释:

  • uname -m用于获取本机架构
  • 注意将/2.14.0/换成所需的版本号,可前往docker-compose的仓库查看详情

记得授予权限 chmod +x ./docker-compose 移动到正确路径 mv ./docker-compose /usr/local/bin/docker-compose

使用ACME脚本申请并配置SSL证书
将旧手机通过Linuxdeploy改造为linux服务器|搭建cloudreve个人网盘|实现离线下载
Valaxy v0.14.61 驱动 | 主题 - Yun v0.14.61
本站已勉强运行0 天0 小时0 分0 秒(ノ`Д)ノ