九、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