MacOS?Docker?安裝的實現(xiàn)步驟
本文講述主要是基于Mac電腦安裝教程,使用的是homebrew安裝,未安裝homebrew的請先自行安裝下
一、使用 Homebrew 安裝
macOS 我們可以使用 Homebrew 來安裝 Docker。Homebrew 的 Cask 已經(jīng)支持 Docker for Mac,因此可以很方便的使用 Homebrew Cask 來進行安裝。
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. 安裝完畢后,從應用中找到Docker 圖標點擊運行??赡軙儐?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) # 服務器信息 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. 試運行docker,使用docker run 運行 hello-world鏡像
- doker 拉取hello-world鏡像:docker pull hello-world
- 運行拉取hello-world鏡像:docker run hello-world
譯:當運行容器時,使用的鏡像如果在本地中不存在,docker 就會自動從 docker 鏡像倉庫中下載,默認是從 Docker Hub 公共鏡像源下載。
wpf@B-L0Q0JHD2-2029 ~ % docker run hello-world # 運行hello-world Unable to find image 'hello-world:latest' locally # 提示未找到hello-world鏡像 latest: Pulling from library/hello-world # 嘗試拉取遠程官方library下的h-w鏡像 2db29710123e: Pull complete # 拉取完畢了,后面是簽名信息 Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe Status: Downloaded newer image for hello-world:latest Hello from Docker! # 顯示這句話說明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 命令來列出本地主機上的鏡像。
或者直接打開Docker Desktop應用
二、Docker底層運行原理
docker 是一個c/s結構的系統(tǒng)(client客戶端/server服務端)。
Docker的守護進程運行在宿主主機上,通過socket從客戶端訪問。DockerServer 接收到 Docker-Client的指令,就會執(zhí)行這個指令。
Docker會以root權限運行它的守護進程,來處理普通Linux用戶無法完成的操作(如掛載文件系統(tǒng)等操作)
? 說明:8080和3306兩個容器外部是訪問不到的,是屬于容器內(nèi)的,容器就好比一個小的虛擬機,容器之間互相隔離;容器與外部大的Linux服務器也是互相隔離的,一個容器占用的進程資源是非常小的
? Docker執(zhí)行run命令的流程如下:
- Dockers引擎會在本地查找鏡像
- 本地找到鏡像 然后啟動鏡像
- 本地未找到鏡像,然后根據(jù)Docker引擎配置的倉庫地址,遠程去查找鏡像。
- 遠程查詢到鏡像,把鏡像下載到本地,然后啟動鏡像
- 遠程查詢到鏡像,Docker返回錯誤,提示鏡像遠程未找到。
- 運行中的鏡像支持:停止、啟動、重啟、刪除(先停止才可以刪除)操作。
到此這篇關于MacOS Docker 安裝的實現(xiàn)步驟的文章就介紹到這了,更多相關MacOS Docker 安裝內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Docker安裝部署分布式數(shù)據(jù)庫?OceanBase的詳細過程
這篇文章主要介紹了Docker安裝部署分布式數(shù)據(jù)庫?OceanBase,快速的體驗 OceanBase 的自動化部署過程,及了解 OceanBase 集群安裝成功后的目錄特點和使用方法,需要的朋友可以參考下2022-06-06一次dockerfile的循環(huán)依賴錯誤實戰(zhàn)記錄
Dockerfile 是一個文本文件,其內(nèi)包含了一條條的指令,每一條指令構建一層,因此每一條指令的內(nèi)容,就是描述該層應當如何構建,這篇文章主要介紹了使用Docker多階段構建時遇到的循環(huán)依賴問題及其解決方法,,需要的朋友可以參考下2025-02-02Docker如何根據(jù)名稱查詢?nèi)萜鱅D鏡像ID并停止刪除
這篇文章主要介紹了Docker如何根據(jù)名稱查詢?nèi)萜鱅D鏡像ID并停止刪除問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-11-11