首页 > 其他分享 >Alpine中安装docker

Alpine中安装docker

时间:2024-06-11 12:54:43浏览次数:9  
标签:alpinelinux daemon docker Alpine 安装 Docker alpine

alpine 环境中安装 docker
alpine linux 是一个基于安全的轻量级 Linux 发行版,基于 musl libc 和 busybox。alpine linux 由于简单安全,非常适合 docker 的 linux 发行版,并且被 docker 官方所推荐用来取代 ubuntu。它不但非常小,仅有 5m 左右,而且经过优化可以在 RAM 中运行
既然这么省资源,那么本文就尝试在虚拟机中安装 alpine,然后安装 docker
官方文档
下载
alpinelinuxhttps://www.alpinelinux.org/downloads/,这里选择VIRTUAL,它与标准版相似、瘦下来的内核、针对虚拟系统进行了优化。
下载地址链接
下载得到的文件是alpine-virt-3.9.4-x86_64.iso,大小 35m
VMware 中安装
按道理 VirtualBox 也是一样的,VMware 的新建虚拟机的设置中,操作系统类型选择Linux,版本选择其他Linux 4.x 或更高版本内核 64 位
其他步骤按照提示来就行了,问题不大。新建完后启动虚拟机
设置 alpine
启动之后进入安装步骤
具体步骤参考 https://wiki.alpinelinux.org/wiki/Install_to_disk
可参考博客: Alpine linux 硬盘安装、 alpine linux docker 安装体验
apk 介绍
Alpine Linux 的软件包是经过数字签名的 tar.gz 存档,包含程序,配置文件和依赖关系元数据。它们具有扩展名.apk,通常称为“a-packs”。包存储在一个或多个存储库中。
相关文档,包含常用命令及介绍。 https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management
包搜索地址
有些包可能在社区的源才有,地址: http://dl-cdn.alpinelinux.org/alpine/latest-stable/community
安装 docker
Docker 包位于“社区”存储库中,因此如果 apk 添加失败且具有不可满足的约束,则需要编辑/etc/apk/repositories文件以添加(或取消注释)一行,如: http://dl-cdn.alpinelinux.org/alpine/latest-stable/community
更新索引存储库apk update
开始安装apk add docker
要在引导时启动 Docker 守护程序,请运行:rc-update add docker boot
然后手动启动 Docker 守护程序,运行:service docker start
参考 alpinelinux Docker

运行

启动service docker start
docker run hello-word

localhost:/etc/docker# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe
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 之后,使用命令docker -v可查看版本,但是容器相关命令出错
localhost:~# docker ps
Cannot connect to the Docker daemon at unix:///var/rundocker.sock. Is the docker daemon running?

通过命令service docker start也启动 docker,`/var/run/docker.sock 也确实存在。
折腾一番之后,查看日志cat ./var/log/docker.log,得到关键信息Error starting daemon: Devices cgroup isn't mounted。
cat ./var/log/docker.log

最后看了官方文档得以解决, https://wiki.alpinelinux.org/wiki/Docker
关键点还是cgroup filesystem的问题,cgroup是什么请自行查询
localhost:/etc/docker# rc-update add docker boot

  • service docker added to runlevel boot
    localhost:/etc/docker# service docker start
  • Mounting cgroup filesystem ...
  • Starting docker ...

所以整个问题的根源是cgroup filesystem没有挂载,在执行rc-update add docker boot后在启动就好了
总结
多次总结,使用一款产品,第一件事就是找到文档,文档实在晦涩难懂的情况,那么可能有翻译版或者国内版,毕竟官方的才是最权威的
其次是每个人用起来遇到的环境可能不一样,遇到的问题也就不一样,但所有的解决思路中,查看日志这一条是我觉得始终应该第一考虑的,它很明白告诉你,出错了,出了什么错,可能还有出错的具体位置以及建议解决方案
end
打开App,阅读手记

作者:大地缸
链接:https://www.jianshu.com/p/7c6973aa1938
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

标签:alpinelinux,daemon,docker,Alpine,安装,Docker,alpine
From: https://www.cnblogs.com/docker-bear/p/18241872

相关文章

  • 禅道安装过程中出现的问题总结
    虽然最终成功安装了,使用的18.12源码版本安装的mac下面,自带apache,使用起来没问题,但是brewinstallphp因为网速原因无法安装,只能选择在linuxarch64架构下使用源码安装。安装的过程中,确认安装apache,使用yuminstall去安装,配置文件 /etc/httpd/conf/httpd.conf中关注Listen监......
  • Macbook M芯片Homebrew与git的安装与配置
    MacbookM芯片Homebrew与git的安装与配置Homebrew的安装与配置搜索Homebrew;找到如下网址https://brew.sh/把以上命令复制到终端执行后,发现并不能下载;如果你像我一样也是不通的,可以使用国内源,将如下命令复制到终端:/bin/zsh-c"$(curl-fsSLhttps://gitee.com/cunkai/H......
  • OpenWrt安装配置Tailscale
    什么是tailscale?Tailscale就是基于Wireguard的一个联网工具,无需公网地址,通过去中心化,实现各个节点之间点对点的连接.配置简单友好,支持的各类平台和客户端.相比较其他组网工具的优势是什么?对比zerotier和wireguard,wireguard更容易连上官方的中转服务器,webui界面更简单,适合......
  • centOS安装python3
    CentOS7安装Python3在CentOS系统上安装Python3的步骤如下:首先,打开终端。安装必要的构建工具和库:sudoyumgroupinstall-y"DevelopmentTools"sudoyuminstall-yzlib-develbzip2-developenssl-develncurses-develsqlite-develreadline-develtk-develgdbm......
  • docker pull镜像加速
    dockerpull镜像,发现一些还能用的sudovim/etc/docker/daemon.json写入{"registry-mirrors":["https://ustc-edu-cn.mirror.aliyuncs.com/","https://ccr.ccs.tencentyun.com/","https://docker.m.daocloud.io/"]}重启dockersudose......
  • Aria2安装教程
    Aria2安装教程时间:2024-3-1922:41:03版本:1.37.0官方下载地址:Releases·aria2/aria2(github.com)打开网址后点击这里。​​拉到最后,选择自己合适的版本下载即可,我选择的是win64版本。​​解压文件夹,放到自己合适的目录下。​​在当前目录新建四个文件:Aria2.log(日志......
  • 白话理解和使用DOCKER VOLUME
    Docker使用Volume来管理宿主机和容器内数据的映射  什么是数据卷(Volume)Docker镜像被存储在一系列的只读层中。当我们创建一个容器时,Docker会读取镜像(只读),并在其顶部添加一层读写层。如果正在运行中的容器修改了现有文件,该文件将会被拷贝出底层的只读层,放到最顶层的读写层中......
  • Android 11.0 mtk浏览器Browser下载应用不能安装问题的解决办法
    1.前言 在系统11.0的ROM定制化开发中,在开发mtk平台的时候,在系统默认浏览器Browser中发现在下载某些app的时候,结果显示的确实在下载到内部存储的时候,点击安装的时候安装失败,所以就需要从Browser的下载流程中出发分析相关源码来实现具体的功能2.mtk浏览器Browser下载应用不能......
  • 笔记本电脑(win11+3060+conda)安装PyTorch踩坑记录
    简而言之,先看你的显卡,打开CMD,输入nvidia-smi,右上角有一个CUDA:XX.X表示当前显卡及当前驱动支持的最高版本CUDA。输入nvidia-smi-q可以看到显卡架构(或者直接去Nvidia官网找你的显卡)。再打开这个连接,查看你显卡架构支持的最低版本CUDA。从中选择一个cuda版本torch是自带了cu......
  • Docker安装SQL Sever
    https://www.cnblogs.com/x666-6/p/18102094拉取镜像 dockerpullmcr.microsoft.com/mssql/server:2022-latest运行容器 docker run -e "ACCEPT_EULA=Y"-e "MSSQL_SA_PASSWORD=ChenDaDliu2023"-p1433:1433--namesql1--hostnamesqlS......