【随笔记】Deepin20 安装docker

Deepin20 安装docker随笔记

Deepin 的内核在很多地方都有介绍,基于Ubuntu、Debian。本次根据ubuntu进行docker的安装

使用官方脚本进行自动安装

这算是Deepin的一个优点吧,按什么都可以直接sudo apt-get install
安装命令如下:

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

使用Docker 仓库进行安装

这个更加简单粗暴
更新apt包索引
测试了,不是必须

$ sudo apt-get update

安装apt依赖包

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

之后就是添加Docker的一个GPG:

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

验证是否成功拥有这个GPG秘钥,这个在官网也能看到,是通用的9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

$ sudo apt-key fingerprint 0EBFCD88
   
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

最后设置一个仓库版本

$ sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
  $(lsb_release -cs) \
  stable"

安装Docker Engine-Community

还是更新一下apt包

不更新也行,感觉上没什么用。我看了没更新下来什么。
也可能是我deepin之前安装过nodejs,好多依赖都提示在nodejs时已经安装过了
安装Docker Engine-Communtiy 和containerd

$ sudo apt-get install docker-ce docker-ce-cli containerd.io add -

这块要说一下,虽然我是根据Ubuntu进行安装的,但是这一步安装后的信息提示中,明确写的是Debian:5:20:2版本,可能是Deepin内核的原因。

测试Docker安装是否成功

输入hello-world 测试是否安装成功,也就是运行一个10+Kb的镜像

$ sudo docker run hello-world

看到巴拉巴拉一堆说明,表示成功:

$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete                                                                                                                                  Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
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/

到这Deepin20安装docker成功

Deepin20 在Docker中安装CentOS7

接着上面安装centOS7

直接开整,拉取CentOS7的镜像

$ sudo docker pull centos:centos7

安装后查看已经安装的镜像

$ sudo docker images

这里会把你环境中的全部docker镜像列出来(所以hello-world也会出现,就是上面说的那个10+Kb的镜像)

REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
centos        centos7   8652b9f0cb4c   7 weeks ago     204MB
hello-world   latest    bf756fb1ae65   12 months ago   13.3kB

进入centOS

这里没有加 /bin/bash 另外用-d指定了容器运行模式,所以不会直接进入容器,也就是容器会在后台运行

$ sudo docker run -itd --name centos-test centos:centos7

可以使用PS命令查看容器运行信息

$ sudo docker ps

停止所有容器

$ sudo docker ps -a

停止一个指定的容器

$ sudo docker stop 容器ID

进入容器

attach直接进入,退出后容器会停止;docker exec 退出后,容器不会停止

另外如果容器没有运行需要先把容器启动

$ sudo docker start 容器ID

$ sudo docker attach 容器ID
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值