#=================================================
# Docker 安裝:
# 首選: https://docs.docker.com/engine/install/ubuntu/
# 次: https://docs.docker.com/compose/install/linux/
#=================================================
# -----------
# 設置存儲庫
#------------
# 1.更新apt包索引並安裝包以允許apt通過 HTTPS 使用存儲庫:
sudo apt-get update
sudo apt-get upgrade # --fix-missing
sudo sudo apt-get install ca-certificates curl gnupg
# 2.添加 Docker 的官方 GPG 密鑰
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# 3.使用以下命令設置存儲庫:
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# -----------------
# 安裝 Docker 引擎
#------------------
# 1. 更新apt包索引:
sudo apt-get update
# // 運行時收到 GPG 錯誤apt-get update? //
# // 您的默認umask可能配置不正確,導致無法檢測存儲庫公鑰文件。在更新包索引之前嘗試授予 Docker 公鑰文件的讀取權限:
sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt-get update
# 2.安裝 Docker Engine、containerd 和 Docker Compose
# 2.1 最新的
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt-get install docker-ce
sudo apt-get install docker-ce-cli
sudo apt-get install containerd.io
sudo apt-get install docker-buildx-plugin
sudo apt-get install docker-compose-plugin
# 2.2 具體版本
# List the available versions:
apt-cache madison docker-ce | awk '{ print $3 }'
5:20.10.16~3-0~ubuntu-jammy
5:20.10.15~3-0~ubuntu-jammy
5:20.10.14~3-0~ubuntu-jammy
5:20.10.13~3-0~ubuntu-jammy
# 選擇所需版本並安裝:
VERSION_STRING=5:20.10.13~3-0~ubuntu-jammy
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING install containerd.io
sudo apt-get install docker-buildx-plugin
sudo apt-get install docker-compose-plugin
# 3. 通過運行鏡像驗證 Docker Engine 安裝是否成功 hello-world
sudo docker run hello-world
# 4. Docker 守護進程自動啟動
sudo service docker start
# -------------------------
# 安裝 Docker-compose 引擎
#--------------------------
sudo apt-get install docker-compose-plugin
sudo apt-get upgrade docker-compose
#=====================================================================
https://philipzheng.gitbook.io/docker_practice/install/ubuntu
#########################
# 1、透過系統內建套件安裝
#########################
# Ubuntu 14.04 版本套件庫中已經內建了 Docker 套件,可以直接安裝。
$ sudo apt-get update
$ sudo apt-get install -y docker.io
$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
$ sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker
############################################
# 2、如果使用作業系統內建套件安裝 Docker,
# 目前安裝的版本是比較舊的 0.9.1。
# 要安裝更新的版本,可以透過更新 Docker
# 套件庫的方式進行安裝。
############################################
#透過Docker 套件庫安裝最新版本
#要安裝最新的 Docker 版本,首先需要安裝 apt-transport-https 支援,之後透過新增套件庫來安裝。
$ sudo apt-get install apt-transport-https
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo bash -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update
$ sudo apt-get install -y lxc-docker
###########################
# 3、快速安裝法(建議使用)
##########################
$ curl -sSL https://get.docker.com/ubuntu/ | sudo sh
# 14.04 之前版本
# 如果是較舊版本的 Ubuntu 系統,需要先更新核心。
$ sudo apt-get update
$ sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
$ sudo reboot
# 然後重複上面的步驟即可。
############################
# 安裝之後啟動 Docker 服務。
############################
$ sudo service docker start
#==================================================
# portainer 安裝:
# 首選: https://hub.docker.com/r/portainer/portainer
# CE版: https://docs.portainer.io/start/install-ce/server/docker/linux
#==================================================
# 安裝後更新,要reboot
sudo apt-get update
sudo apt-get upgrade
#portainer instasll
// sudo docker pull portainer/portainer
sudo docker volume create portainer_data
#------------------------------------------------------
#sudo docker run -d -p 8000:8000 -p 9443:9443 \
# --name portainer --restart=always \
# -v /var/run/docker.sock:/var/run/docker.sock \
# -v portainer_data:/data portainer/portainer-ce:latest
#-----------------------------------------------------------
sudo docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
#測試
https://127.0.0.1:9443
sudo docker ps
#==================================================
#一. 建立 Docker Registry Server
#*直接透過啟動 Docker container 的方式,
# 就可以把 Docker Registry Server 建立起來,
# 指令如下:
#==================================================
# sudo docker run
# -p 5000:5000 \
# -d \ # run 在背景的狀態
# -v /home/user1/storage:/var/lib/registry
# --name registry registry:2 # 設定 docker container 的名稱
#--------------------------------------------------
sudo docker run -d -p 5000:5000 -v /home/user1/storage:/var/lib/registry --name registry registry:2
#--------------------------------------------------
# 在 Portainer | Registries 頁上 按 [+Add Registry]
#--------------------------------------------------
# Name : [MyRegistriesName]
# Registry URL : [https://IP:5000]
# Authentication:[Enable]
# AWS Access Key:[root]
# AWS Secret Access Key:[Password]
# Region : [Password]
# -------------------------------------------------
#--------------------------------------------------
# 1. 需先對 image 執行 tag 處理
# docker tag <imageId or imageName> <nexus-hostname>:<repository-port>/<image>:<tag>
#--------------------------------------------------
sudo docker tag imageIdXX 192.168.40.128:5000/hello-world:mytag
#--------------------------------------------------
# 2. Docker Image Push 到 Docker Registry Server
# docker tag af340544ed62 nexus.example.com:18444/hello-world:mytag
#--------------------------------------------------
sudo docker push 192.168.40.128:5000/hello-world:mytag
#--------------------------------------------------
# 若沒成功則: 修改/etc/docker/daemon.json 如下
#--------------------------------------------------
sudo nano /etc/docker/daemon.json
#
# {
# "live-restore": true,
# "group": "dockerroot",
# "insecure-registries": ["192.168.1.148:5000"]
# }
#
#--------------------------------------------------
# 重新啟動 Docker 的 service 指令如下
#--------------------------------------------------
sudo systemctl restart docker
#--------------------------------------------------
# Pull docker image 指令如下
#--------------------------------------------------
sudo docker push 192.168.1.148:5000/MyImagesTagName
sudo docker push 192.168.40.128:5000/portainer/portainer-ce:latest
#=======<< Nifi compose file>>=================================
# https://www.youtube.com/watch?v=ELjxyxO805E
#--------------------------------------------------
git clone https://github.com/chnbohwr/nifi_compose.git
#=======<<xx Nifi >>=================================
# sudo docker run --name nifi
# -p 8443:8443 \
# -d \
# -e NIFI_WEB_HTTPS_PORT='8443'
# -e NIFI_WEB__HOST='192.168.1.147:8443'
# -e SINGLE_USER_CREDENTIALS_USERNAME=admin \
# -e SINGLE_USER_CREDENTIALS_PASSWORD=abcd1234 \
# apache/nifi:latest
#--------------------------------------------------
sudo docker run --name nifi -p 8443:8443 -d -e NIFI_WEB_HTTPS_PORT=8443 -e NIFI_WEB_HTTPS_PORT='8443' -e NIFI_WEB_PROXY_HOST='192.168.1.147:8443' -e SINGLE_USER_CREDENTIALS_USERNAME='admin' -e SINGLE_USER_CREDENTIALS_PASSWORD='abcd1234' apache/nifi:latest
#確認 CONTAINER 是否在執行
user@docker:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5ec9b33ad204 apache/nifi:latest "../scripts/start.sh" 19 seconds ago Up 13 seconds 8000/tcp, 8080/tcp, 10000/tcp, 0.0.0.0:8443->8443/tcp, :::8443->8443/tcp nifi
# 篩檢 log 內容, 尋找Username/Password
user@docker:~$ sudo docker logs nifi | grep Generated
ERROR: Password must be at least 12 characters
tail: cannot open '/opt/nifi/nifi-current/logs/nifi-app.log' for reading: No such file or directory
tail: '/opt/nifi/nifi-current/logs/nifi-app.log' has appeared; following new file
2023-03-31 06:15:01,636 INFO [main] org.apache.nifi.bootstrap.Command Generated Self-Signed Certificate SHA-256: D85C179486A1FFE79EEFF0470D0E786B60446D1D5100CCC7AB941CF67B6D81D1
Generated Username [b11e4642-ffa2-4fe6-8e53-37d201a8ed8b]
Generated Password [+pNlTCUisGDqLhQIBEOVaQwYcHzCeF/e]
#================================================
# 安裝NiFi在Docker →可用步驟
#
# [Docker](https://hub.docker.com/r/apache/nifi)
#================================================
# PULL Image 檔下來
sudo apt-get update
sudo apt-get upgrade docker-compose
sudo docker pull apache/nifi
#---------------------------------------------------------------
# 創作一個 Container -e NIFI_WEB_PROXY_HOST=”要輸入該設備的IP”
#
#--<範例>-------------------------------------------------------
# docker container run
# --name nifi
# -p 8443:8443
# -v /nifidata : /opt/nifi/nifi-current/docs
# -d
# -e NIFI_WEB_HTTPS_PORT=8443
# -e NIFI_WEB_PROXY_HOST='192.168.40.128:8443'
# apache/nifi:latest
# --------------------------------------------------------------
sudo docker container run --name nifi -p 8443:8443 -v /nifidata:/opt/nifi/nifi-current/docs -d -e NIFI_WEB_HTTPS_PORT=8443 -e NIFI_WEB_PROXY_HOST='192.168.40.129:8443' apache/nifi:latest
sudo docker container run --name nifi -p 8443:8443 -v /nifidata:/opt/nifi/nifi-current/docs -d -e NIFI_WEB_HTTPS_PORT=8443 -e NIFI_WEB_PROXY_HOST='192.168.40.128:8443' apache/nifi:latest
#---------------------------------------------------------------
# 看創建的Container有沒有成功,順便記一下ID
#---------------------------------------------------------------
sudo docker ps
#---------------------------------------------------------------
# 看帳密
#---------------------------------------------------------------
sudo docker logs nifi | grep Generated
# 可以看到帳密
# enerated Username [USERNAME]
# Generated Password [PASSWORD]
#---------------------------------------------------------------
# 用 Edge https://192.168.xx.xxx:8443
#
# 輸入找到的帳密
#---------------------------------------------------------------
# 其他問題:
#...............................................................
# ![Untitled](https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b47614d8-6e21-4bd1-af91-5211cec69f71/Untitled.png)
#
# SOL: 結果有可能是電腦主機與VM之間的防火牆與網路連結問題,要先看看主機本身可否被ping或開啟通訊埠口
#
# [Apache NiFi - The request contained an invalid host header](https://stackoverflow.com/questions/48771728/apache-nifi-the-request-contained-an-invalid-host-header)
#...............................................................
sudo apt-get upgrade docker-compose
沒有留言:
張貼留言