九、Docker安装常见系统


BusyBox

BusyBox简介

集成了一百多个最常用的Linux命令的镜像,不到2M。

 获取镜像

$docker search busybox

官方下完1.22M

$docker pull busybox:latest

运行busybox

运行之后会进入如下所示,可以直接输入命令,exit退出

[root@localhost test]# docker run -it busybox
WARNING: IPv4 forwarding is disabled. Networking will not work.
/ #

Alpine

Alpine简介

一个面向安全的轻量级linux操作系统,大小5M左右,占用资源小,自带BusyBox跟包管理工具apk等。

获取镜像

因为小所以爱可以直接运行并下载

$docker run alpine echo ‘我很小’

用time查看下载运行需要多久

[root@localhost test]# time docker run alpine echo "我很小"
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
Image docker.io/library/alpine:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
c9b1b535fdd9: Already exists
Digest: sha256:ccf1a7a4018644cdc8e1d50419bbccb08d8350109e6c2e757eef87ee2629828a
Status: Downloaded newer image for alpine:latest
WARNING: IPv4 forwarding is disabled. Networking will not work.
我很小

real    0m1.583s
user    0m0.032s
sys     0m0.056s
View Code

运行界面跟busybox一样

迁移至Alpine基础镜像

这个书里写的没搞懂,百度了也没结果,有谁知道的可以留个言

image

alpine支持apk安装软件包,软件包名可能与其他发行版不同,再官网搜索软件包确定名称后再下载。

https://pkgs.alpinelinux.org/packages

image

如果软件包不在官网,再测试或社区网站上,需要先更新仓库列表

$ echo "http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
$ apk --update add --no-cache wget

Debian/Ubuntu

Debian简介

都是Debian系服务器操作系统,用于个人电脑跟服务器中,其他都是废话。

 获取镜像与使用

$docker search debian
$docker run -it debian bash
 
 
#搜索评星50以上的ubuntu镜像
$docker search –filter=stars=50 ubuntu
$docker run -it ubuntu:18.04 /bin/bash
root@7d93de07bf76:/# cat /etc/os-release

先更新再安装

root@7d93de07bf76:/# apt-get update
#安装curl跟apache2并启动
root@7d93de07bf76:/# apt-get install curl
root@7d93de07bf76:/# apt-get install -y apache2
root@7d93de07bf76:/# service apache2 start

CentOS/Fedora

CentOS简介

CentOS/Fedora都是基于Redhat的发行版,前者用于企业级服务器操作系统,后者面向个人PC。

获取镜像与使用

$ docker search -f stars=25 centos
$ docker run -it centos bash
[root@43eb3b194d48 /]# cat /etc/redhat-release

$ docker search -f stars=2 fedora
$ docker run -it fedora bash
[root@196ca341419b /]# cat /etc/redhat-release

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM