Linux安装Docker

安装环境:Deepin 15.9,基于Debian 9(代号stretch)开发,全部操作都是在root用户下进行

root@realjt-pc ~ $ cat /etc/debian_version
9.0

查看官方文档

文档地址:https://docs.docker.com/install/linux/docker-ce/debian,在Debian系统中安装Docker有多种方式,例如通过APT安装,Deepin仓库维护的Docker版本一般不是最新的,如果需要安装最新版本的Docker,则需要添加Docker官方仓库地址,比较麻烦,我们继续翻阅文档,发现通过下载deb包安装非常简单。

在这里插入图片描述

下载所需要的安装包

根据官方文档描述,访问下载地址:https://download.docker.com/linux/debian/dists,选择需要的Debian版本文件夹,再进入pool/stable文件夹,然后根据CPU架构按需选择,这里最终选择的路径为https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/,看到的文件如下

在这里插入图片描述

分别选择下载containerd.io,docker-ce-cli,docker-ce的最新版本

安装deb包

  1. 安装containerd.io包
root@realjt-pc ~ $ dpkg -i containerd.io_1.2.4-1_amd64.deb
正在选中未选择的软件包 containerd.io。
(正在读取数据库 ... 系统当前共安装有 190331 个文件和目录。)
正准备解包 containerd.io_1.2.4-1_amd64.deb  ...
正在解包 containerd.io (1.2.4-1) ...
正在设置 containerd.io (1.2.4-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
  1. 安装docker-ce-cli包
root@realjt-pc ~ $ dpkg -i docker-ce-cli_18.09.3~3-0~debian-stretch_amd64.deb
正在选中未选择的软件包 docker-ce-cli。
(正在读取数据库 ... 系统当前共安装有 190354 个文件和目录。)
正准备解包 docker-ce-cli_18.09.3~3-0~debian-stretch_amd64.deb  ...
正在解包 docker-ce-cli (5:18.09.3~3-0~debian-stretch) ...
正在设置 docker-ce-cli (5:18.09.3~3-0~debian-stretch) ...
正在处理用于 man-db (2.8.3-2) 的触发器 ...
  1. 安装docker-ce包
root@realjt-pc ~ $ dpkg -i docker-ce_18.09.3~3-0~debian-stretch_amd64.deb
(正在读取数据库 ... 系统当前共安装有 190544 个文件和目录。)
正准备解包 docker-ce_18.09.3~3-0~debian-stretch_amd64.deb  ...
正在将 docker-ce (5:18.09.3~3-0~debian-stretch) 解包到 (5:18.09.3~3-0~debian-stretch)...
正在设置 docker-ce (5:18.09.3~3-0~debian-stretch) ...
update-alternatives: 使用 /usr/bin/dockerd-ce 来在自动模式中提供 /usr/bin/dockerd (dockerd)
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
正在处理用于 systemd (238-5) 的触发器 ...

配置国内镜像加速地址

从阿里云网站获取个人的镜像服务加速地址,并配置到/etc/docker/daemon.json(不存在则新建)文件中

cat /etc/docker/daemon.json
{
  "registry-mirrors": ["https://xxxxx.mirror.aliyuncs.com"]
}

然后重启docker

systemctl daemon-reload
systemctl restart docker

运行hello-world

root@realjt-pc ~ $ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
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/

后续操作

  1. 启动停止
systemctl start/stop docker

或者

service docker start/stop
  1. 开机自启动
systemctl enable/disable docker
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值