MacOS?Docker?安裝的實(shí)現(xiàn)步驟
本文講述主要是基于Mac電腦安裝教程,使用的是homebrew安裝,未安裝homebrew的請(qǐng)先自行安裝下
一、使用 Homebrew 安裝
macOS 我們可以使用 Homebrew 來(lái)安裝 Docker。Homebrew 的 Cask 已經(jīng)支持 Docker for Mac,因此可以很方便的使用 Homebrew Cask 來(lái)進(jìn)行安裝。
1. 輸入安裝命令如下:
brew install --cask --appdir=/Applications docker # 1.輸入安裝命令 ==> Creating Caskroom at /usr/local/Caskroom ==> We'll set permissions properly so we won't need sudo in the future Password: # 2.輸入你的macOS 密碼 ==> Satisfying dependencies ==> Downloading https://download.docker.com/mac/stable/21090/Docker.dmg #################################################################### 100.0% ==> Verifying checksum for Cask docker ==> Installing Cask docker ==> Moving App 'Docker.app' to '/Applications/Docker.app'. 🍺 docker was successfully installed!
最后如果提示了successfully installed! 字樣就表示安裝成功了
2. 安裝完畢后,從應(yīng)用中找到Docker 圖標(biāo)點(diǎn)擊運(yùn)行??赡軙?huì)詢問(wèn) macOS 登陸密碼,輸入即可
3. 打開終端,輸入命令顯示docker的版本信息
wpf@B-L0Q0JHD2-2029 ~ % docker --version # 1.該命令僅顯示安裝版本 Docker version 20.10.22, build 3a2c30b wpf@B-L0Q0JHD2-2029 ~ % docker version # 2.該命令顯示docker具體版本信息 Client: # 客戶端信息 Cloud integration: v1.0.29 Version: 20.10.22 API version: 1.41 Go version: go1.18.9 Git commit: 3a2c30b Built: Thu Dec 15 22:28:41 2022 OS/Arch: darwin/amd64 Context: default Experimental: true Server: Docker Desktop 4.16.1 (95567) # 服務(wù)器信息 Engine: Version: 20.10.22 API version: 1.41 (minimum version 1.12) Go version: go1.18.9 Git commit: 42c8b31 Built: Thu Dec 15 22:26:14 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.14 GitCommit: 9ba4b250366a5ddde94bb7c9d1def331423aa323 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0 wpf@B-L0Q0JHD2-2029 ~ %
4. 試運(yùn)行docker,使用docker run 運(yùn)行 hello-world鏡像
- doker 拉取hello-world鏡像:docker pull hello-world
- 運(yùn)行拉取hello-world鏡像:docker run hello-world
譯:當(dāng)運(yùn)行容器時(shí),使用的鏡像如果在本地中不存在,docker 就會(huì)自動(dòng)從 docker 鏡像倉(cāng)庫(kù)中下載,默認(rèn)是從 Docker Hub 公共鏡像源下載。
wpf@B-L0Q0JHD2-2029 ~ % docker run hello-world # 運(yùn)行hello-world Unable to find image 'hello-world:latest' locally # 提示未找到hello-world鏡像 latest: Pulling from library/hello-world # 嘗試?yán)∵h(yuǎn)程官方library下的h-w鏡像 2db29710123e: Pull complete # 拉取完畢了,后面是簽名信息 Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe Status: Downloaded newer image for hello-world:latest Hello from Docker! # 顯示這句話說(shuō)明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/ wpf@B-L0Q0JHD2-2029 ~ %
5. 我們可以使用 docker images 命令來(lái)列出本地主機(jī)上的鏡像。
或者直接打開Docker Desktop應(yīng)用
二、Docker底層運(yùn)行原理
docker 是一個(gè)c/s結(jié)構(gòu)的系統(tǒng)(client客戶端/server服務(wù)端)。
Docker的守護(hù)進(jìn)程運(yùn)行在宿主主機(jī)上,通過(guò)socket從客戶端訪問(wèn)。DockerServer 接收到 Docker-Client的指令,就會(huì)執(zhí)行這個(gè)指令。
Docker會(huì)以root權(quán)限運(yùn)行它的守護(hù)進(jìn)程,來(lái)處理普通Linux用戶無(wú)法完成的操作(如掛載文件系統(tǒng)等操作)
? 說(shuō)明:8080和3306兩個(gè)容器外部是訪問(wèn)不到的,是屬于容器內(nèi)的,容器就好比一個(gè)小的虛擬機(jī),容器之間互相隔離;容器與外部大的Linux服務(wù)器也是互相隔離的,一個(gè)容器占用的進(jìn)程資源是非常小的
? Docker執(zhí)行run命令的流程如下:
- Dockers引擎會(huì)在本地查找鏡像
- 本地找到鏡像 然后啟動(dòng)鏡像
- 本地未找到鏡像,然后根據(jù)Docker引擎配置的倉(cāng)庫(kù)地址,遠(yuǎn)程去查找鏡像。
- 遠(yuǎn)程查詢到鏡像,把鏡像下載到本地,然后啟動(dòng)鏡像
- 遠(yuǎn)程查詢到鏡像,Docker返回錯(cuò)誤,提示鏡像遠(yuǎn)程未找到。
- 運(yùn)行中的鏡像支持:停止、啟動(dòng)、重啟、刪除(先停止才可以刪除)操作。
到此這篇關(guān)于MacOS Docker 安裝的實(shí)現(xiàn)步驟的文章就介紹到這了,更多相關(guān)MacOS Docker 安裝內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Docker安裝部署分布式數(shù)據(jù)庫(kù)?OceanBase的詳細(xì)過(guò)程
這篇文章主要介紹了Docker安裝部署分布式數(shù)據(jù)庫(kù)?OceanBase,快速的體驗(yàn) OceanBase 的自動(dòng)化部署過(guò)程,及了解 OceanBase 集群安裝成功后的目錄特點(diǎn)和使用方法,需要的朋友可以參考下2022-06-06一次dockerfile的循環(huán)依賴錯(cuò)誤實(shí)戰(zhàn)記錄
Dockerfile 是一個(gè)文本文件,其內(nèi)包含了一條條的指令,每一條指令構(gòu)建一層,因此每一條指令的內(nèi)容,就是描述該層應(yīng)當(dāng)如何構(gòu)建,這篇文章主要介紹了使用Docker多階段構(gòu)建時(shí)遇到的循環(huán)依賴問(wèn)題及其解決方法,,需要的朋友可以參考下2025-02-02Docker如何根據(jù)名稱查詢?nèi)萜鱅D鏡像ID并停止刪除
這篇文章主要介紹了Docker如何根據(jù)名稱查詢?nèi)萜鱅D鏡像ID并停止刪除問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11docker容器非root用戶提權(quán)的問(wèn)題解決
本文主要介紹了docker容器非root用戶提權(quán)的問(wèn)題解決,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04