跳到主要內容

Ubuntu-使用 Shell 安裝 Docker Engine

目的:為服務器安裝Docker Engine
  • Shell內容
#!/bin/bash
function yellow(){
echo -e "\033[33m[$1]\033[0m"
}
yellow "---------安裝docker---------"
sudo apt-get update && \
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
sudo apt-key fingerprint 0EBFCD88 && \
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable" && \
sudo apt-get update && \
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose && \
yellow "---------一般使用者直接執行docker指令---------"
#創建一個docker群組
sudo groupadd docker
#把當前用戶添加到docker群組
sudo usermod -aG docker $USER
#newgrp docker刷新對docker群組的更改或是重新啟動虛擬機器
yellow "---------重新開機---------"
read -p 'do you want to reboot ? [Y/N]' inputs
if [ "$inputs"x == 'n'x ] || [ "$inputs"x == 'N'x ]
then
echo "Please reboot after other actions are completed"
else
sudo reboot
fi
  • 添加執行權限給shell檔:chmod +x <shell檔名>.sh
  • 最後詢問重新開機,如果要立即重新開機輸入 y ,需要再執行其他作業輸入n
參考來源:
1.Install Docker Engine on Ubuntu
https://docs.docker.com/engine/install/ubuntu/
2.Post-installation steps for Linux
https://docs.docker.com/engine/install/linux-postinstall/

留言

這個網誌中的熱門文章

Linux-CentOS7 使用 Bind 架設 DNS Server & DNS正解

DNS (Domain Name System)服務 提供域名解析,相較於IP位址(IP Address),域名(Domain name)讓使用者容易記憶,使用域名對應IP位址。 1.安裝 BIND 套件 # sudo yum install bind

Windows-使用 PowerShell 更改 RDP Port Number & 調整防火牆規則

目的: 服務器在啟用遠端桌面預設值為"3389",因為對管理上有風險,所以需要更改遠端桌面的端口號、調整防火牆規則增加安全性。 PowerShell內容  GitHub:https://github.com/minyufu/powershell.git function Pause(){ [System.Console]::Write('按任意鍵繼續...') [void][System.Console]::ReadKey(1) } #用途:更改預設RDP端口號並添加防火牆規則 Write-Output "-----目前RDP使用端口號-----" $Now_RDP_PortNumber = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal*Server\WinStations\RDP-TCP\" -Name PortNumber | Select-Object PortNumber Write-Output "PortNumber: $Now_RDP_PortNumber" #使用者輸入需要修改的端口號: $New_Rdp_PortNumber = Read-Host -Prompt '輸入新的RDP端口號' #設定新的端口號 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal*Server\WinStations\RDP-TCP\" -Name PortNumber -Value $New_Rdp_PortNumber #加入TCP防火牆規則 New-NetFirewallRule -DisplayName "遠程桌面(TCP-In) $New_Rdp_PortNumber" -Direction Inbound -Protocol TCP -Profile Any -LocalPort $New_Rdp_PortNumber -Action allow Write-Output "遠程桌面(TCP...

Linux-CentOS7 Bind 設置 DNS反解(rDNS) & 增加次要(Slave)伺服器

DNS 反解 : 將IP轉換成域名,通常需要 Class C 或是跟上層網路業者申請 ➽此使用內部網路做DNS反解測試。 1.在主設定檔(/etc/named.conf)添加反解區域(240.168.192.in-addr.arpr) # sudo vim /etc/named.conf zone "240.168.192.in-addr.arpa" IN { type master; file "240.168.192.txt"; }; 2.編輯 反解區域檔案(240.168.192.txt),完成後儲存檔案 # sudo vim/var/named/240.168.192.txt 3.重新啟動 Bind 服務&查看 Bind 服務狀態 # sudo systemctl restart named # sudo systemctl status named 4.使用 nslookup 工具測試 server xxx.xxx.xxx.xxx  --> 指定 DNS 服務器 反解測試完成!! DNS次要(Slave)服務器: 主要減少主伺服器的負擔,還有DNS服務器備機的用途。 1.在主要(Master)DNS服務器,正解及反解區域添加: allow-transfer { }; notify yes; 2.重啟主要(Master)DNS服務器的 Bind 服務 # sudo system restart named 3.次要(Slave)服務器安裝 Bind # sudo yum install -y bind 4.編輯 Slave 的 Bind 主設定檔 # sudo vim /etc/named.conf listen-on port 53 {}; //加入次要服務器 IP allow-query {}; //開放允許查詢的網段 // 加入正解區域 zone "brookdns.local" IN { type slave; masters {192.168.240.14...