WTF is Docker ???

Docker

為什麼要用Docker

比起一般的虛擬化,使用 Docker 有許多優勢

一般的VM v.s. Docker

比較

install

$ curl -sSL https://get.docker.com/ubuntu/ | sudo sh

images(映像)

例如:一個映像檔可以包含一個完整的 ubuntu 作業系統環境,裡面僅安裝了使用者需要的其它應用程式。

container(容器)

容器是從映像檔建立的執行實例。它可以被啟動、開始、停止、刪除。每個容器都是相互隔離的平台。

registry(倉庫)

Docker Hub => link

docker pull(取得映像檔)

$ docker pull bcbcarl/hollywood

docker images(列出)

$ docker images
REPOSITORY                             TAG       IMAGE ID       CREATED        SIZE
isg                                    latest    e13fd8a649e8   3 days ago     3.68GB
mcr.microsoft.com/devcontainers/base   jammy     46ddc7dc0a15   3 months ago   661MB
fathyb/carbonyl                        latest    173e471b5251   9 months ago   274MB
bcbcarl/hollywood                      latest    8a85ac985999   5 years ago    533MB

dockerfile

FROM

FROM <image>
FROM <image>:<tag>

example:

FROM ubuntu

Screenshot 2023-12-01 at 2.35.20 PM

RUN

RUN <command>
RUN ["executable", "<param1>", "<param2>"]

example:

RUN apt update\
    && apt upgrade

ENV

ENV <key> <value>

example


1
{"title":"Docker","description":"explain what is Docker","contributors":"[{\"id\":\"e0c7dab8-be31-4e15-a8e7-22968131e3e1\",\"add\":2727,\"del\":958}]"}
   changed 2 years ago 211 views
   owned this note