国产欧美日韩第一页|日本一二三不卡视频|在线精品小视频,亚洲第一免费播放区,metcn人体亚洲一区,亚洲精品午夜视频

Ubuntu安裝docker教程

2025-01-16 13:48:04 1180

Docker 作為一款強大的容器化工具,在軟件開發(fā)與運維領(lǐng)域應(yīng)用廣泛。若想在 Ubuntu 系統(tǒng)上順利安裝 Docker,需做好一系列準備與操作。接下來,就為大家詳細介紹在 Ubuntu 系統(tǒng)中從安裝準備到最終完成 Docker 安裝及相關(guān)配置的全過程。

一、安裝準備:

1、安裝虛擬機軟件VMWare(上一篇教程是以安裝VMWare舉例,但在windows11系統(tǒng)可能會出現(xiàn)問題,建議有出現(xiàn)問題的自行安裝高版本VMWare)

2、務(wù)必先安裝配置完Ubuntu系統(tǒng)再安裝docker

3、切換到root用戶運行。注意:以后所有docker命令都要基于root運行

二、安裝

(有學(xué)過linux的直接跳過這步,用腳本安裝)

1、環(huán)境配置

更新軟件

 sudo apt update
 sudo apt upgrade
 sudo apt full-upgrade

1、首先,安裝必要的證書并允許 apt 包管理器使用以下命令通過 HTTPS 使用存儲庫:

由于 apt 源使用 HTTPS 以確保軟件下載過程中不被篡改。因此,我們首先需要添加使用 HTTPS 傳輸?shù)能浖约?CA 證書

 sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release

2、Add Docker’s official GPG key:

為了確認所下載軟件包的合法性,需要添加軟件源的 GPG 密鑰

 curl -fsSL http://www.tjdsmy.cn/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

3、Use the following command to set up the repository:

向 source.list 中添加 Docker 軟件源

image.png


2、Install Docker Engine

  1. Update the apt package index:

     sudo apt-get update

  2. Install Docker Engine, containerd, and Docker Compose.

    To install the latest version, run:

     sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin


  3. Verify that the Docker Engine installation is successful by running the hello-world image.

     sudo docker run hello-world

    This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.

      You have now successfully installed and started Docker Engine.

安裝完成后,運行如下命令驗證 Docker 服務(wù)是否在運行:

 systemctl status docker

如果沒有運行,運行以下命令運行 Docker 服務(wù):

 sudo systemctl start docker

使 Docker 服務(wù)在每次重啟時自動啟動:

 sudo systemctl enable docker

可以使用以下命令查看已安裝的 Docker 版本:

 sudo docker version

3、安裝端口測試工具

1、TCPing依賴項:tcptraceroute

 apt install -y tcptraceroute

2、下載TCPing到/usr/bin目錄

image.png

3、賦予TCPing工具執(zhí)行權(quán)限

 chmod +x /usr/bin/tcping

使用

 tcping [目標主機IP] [端口](默認是:80)

如:

image.png

三、腳本安裝

vim installdocker.sh

image.png


四、拍攝快照

將系統(tǒng)破壞了還能還原

配置鏡像加速(安裝在阿里云服務(wù)器才需要做)

當下載鏡像很慢嘗試以下配置

對于使用 systemd 的系統(tǒng),請在 /etc/docker/daemon.json 中寫入如下內(nèi)容(如果文件不存在請新建該文件)

阿里云鏡像加速地址配置:

image.png

搜索 容器鏡像服務(wù)

image.png

image.png

注意,一定要保證該文件符合 json 規(guī)范,否則 Docker 將不能啟動。

之后重新啟動服務(wù)。

sudo systemctl daemon-reload
 sudo systemctl restart docker

netstat -luntp #查看所有服務(wù)啟動后端口是否被偵聽這個很重要

通過上述步驟,我們能在 Ubuntu 系統(tǒng)上成功安裝并配置好 Docker,不僅確保其正常運行,還能通過鏡像加速優(yōu)化下載速度,借助端口測試工具排查網(wǎng)絡(luò)問題。這些操作將為后續(xù)使用 Docker 進行容器化開發(fā)與部署筑牢根基,助力高效的項目推進。

想了解更多Docker相關(guān)的分享歡迎上藍隊云官網(wǎng)查詢,更多免費技術(shù)學(xué)習(xí)文檔,藍隊云期待與您一起探索。


提交成功!非常感謝您的反饋,我們會繼續(xù)努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務(wù),我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: