离线部署-docker

离线,部署,docker · 浏览次数 : 10

小编点评

当然,以下内容需要带简单的排版: ``` network_mode: \"host\"volumes: cogent-admin-data: mediakit-data: mysql-data: mysql_conf_data: mysql_log_data: redis-data: minio-data:mysql的数据文件不能和日志文件等放到一起,否则启动时会报错,说数据目录已经有文件对应用进行初始化如果你有在初次部署时有对某些应用进行初始化的操作,比如我需要在初次部署时,将minio创建Access key,创建默认bucket,开启webhook。那么可以在minio容器启动后:# check minio is runningif pgrep -x \"minio\" >/dev/null; then techo \"minio init...\"\t# minio deploy: create access key and secret key, create bucket, webhook eventchmod +x /opt/bin/mccd /opt/bin || exitmc alias set myminio http://127.0.0.1:9002 ROOTNAME CHANGEME123mc admin user svcacct add --access-key \"xFkEokGRAlwIs1234\" --secret-key \"jaz4FlvCDDKvbBuQYJ9NIohMUlRDsT132465789\" myminio ROOTNAMEmc mb myminio/cogentmc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event putmc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event delete完整的部署脚本:#!/bin/bash# minio deploy: create access key and secret key, create bucket, webhook eventchmod +x /opt/bin/mccd /opt/bin || exitmc alias set myminio http://127.0.0.1:9002 ROOTNAME CHANGEME123mc admin user svcacct add --access-key \"xFkEokGRAlwIs1234\" --secret-key \"jaz4FlvCDDKvbBuQYJ9NIohMUlRDsT132465789\" myminio ROOTNAMEmc mb myminio/cogentmc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event delete完整的部署脚本:#!/bin/bash# if ! which docker >/dev/null 2>&1; then techo \"docker is not installed. Start install docker.\"\t# install docker use offline package cd docker-install || exit tsudo dpkg -i ./containerd.io_1.6.21-1_amd64.deb ./docker-ce_24.0.2-1~ubuntu.20.04~focal_amd64.deb ./docker-ce_cli_24.0.2-1~ubuntu.20.04~focal_amd64.deb ./docker-buildx-plugin_0.10.5-1~ubuntu.20.04~focal_amd64.deb ./docker-compose-plugin_2.18.1-1~ubuntu.20.04~focal_amd64.deb start docker containersdocker compose up -d redis mysql miniodocker compose up -d cogent-admin medikit# check minio is runningif pgrep -x \"minio\" >/dev/null; then techo \"minio init...\"\t# minio deploy: create access key and secret key, create bucket, webhook eventchmod +x /opt/bin/mccd /opt/bin || exitmc alias set myminio http://127.0.0.1:9002 ROOTNAME CHANGEME123mc admin user svcacct add --access-key \"xFkEokGRAlwIs1234\" --secret-key \"jaz4FlvCDDKvbBuQYJ9NIohMUlRDsT132465789\" myminio ROOTNAMEmc mb myminio/cogentmc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event putmc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event delete full deployment script:#!/bin/bash# minio deploy: create access key and secret key, create bucket, webhook eventchmod +x /opt/bin/mccd /opt/bin || exitmc alias set myminio http://127.0.0.1:9002 ROOTNAME CHANGEME123mc admin user svcacct add --access-key \"xFkEokGRAlwIs1234\" --secret-key \"jaz4FlvCDDKvbBuQYJ9NIohMUlRDsT132465789\" myminio ROOTNAMEmc mb myminio/cogentmc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event delete full deployment script:#!/bin/bash# if ! pgrep -x \"minio\" >/dev/null; then techo \"minio is not running. This will influence file upload and download.\"fi minio deploy: create access key and secret key, create bucket, webhook eventchmod +x /opt/bin/mccd /opt/bin || exitmc alias set myminio http://127.0.0.1:9002 ROOTNAME CHANGEME123mc admin user svcacct add --access-key \"xFkEokGRAlwIs1234\" --secret-key \"jaz4FlvCDDKvbBuQYJ9NIohMUlRDsT132465789\" myminio ROOTNAMEmc mb myminio/cogentmc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event putmc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event delete full deployment script:#!/bin/bash# ```

正文

离线部署---docker

关键词:docker离线部署,images离线安装,docker compose,shell,minio

docker离线安装

docker install offline

下载相应的版本的deb包,我的系统是ubuntu20.04,因此选择focal文件夹,路径:

image-20230918160059759

按照文档下载相应的包,挑选自己想要的版本。

从部署脚本中截取安装docker的部分:

#!/bin/bash

echo "Please run this script as root. Because it will install docker and docker-compose.
If you have installed docker and docker-compose, please ignore this message.
And i use docker-compose version is 3.8, so please make sure your docker engine version is 19.03.0+."

echo

# check user is root
whoami=$(whoami)
if [ "$whoami" != "root" ]; then
	echo "Please run as root."
	exit 1
fi

# check docker is installed

# verlt 24.0.5 19.03.0 && echo "yes" || echo "no" # no
# this function check $1 is less than $2
versionLessThan() {
	if [ "$1" = "$2" ]; then
		return 1
	else
		# sort -V: natural sort of (version) numbers within text
		[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
	fi
}

if ! which docker >/dev/null 2>&1; then

	echo "docker is not installed. Start install docker."

	# install docker use offline package
	cd docker-install || exit

	sudo dpkg -i ./containerd.io_1.6.21-1_amd64.deb \
		./docker-ce_24.0.2-1~ubuntu.20.04~focal_amd64.deb \
		./docker-ce-cli_24.0.2-1~ubuntu.20.04~focal_amd64.deb \
		./docker-buildx-plugin_0.10.5-1~ubuntu.20.04~focal_amd64.deb \
		./docker-compose-plugin_2.18.1-1~ubuntu.20.04~focal_amd64.deb

	sudo service docker start

	cd ..
fi

如果当前机器已经安装docker了,那么我检查当前docker engine版本,我用的docker compose版本为3.8,因此我需要docker engine 大于等于 19.03.0

# check docekr engine version
docker_version=$(docker version --format '{{.Server.Version}}')
echo "docker engine version is $docker_version"
# if docker_version less than 19.03.0, exit
if versionLessThan "$docker_version" "19.03.0"; then
	echo "docker engine version is less than 19.03.0, please upgrade docker engine."
	exit 1
fi

离线安装镜像

将docker镜像备份:docker save -o yourImage.tar company/yourImage:v1.0

将备份的tar上传到离线的机器,加载镜像:docker load -i yourImage.tar

docker compose 启动容器

镜像加载好后,就可以用docker compose启动容器了

我的docker compose:

version: "3.8"
services:
  cogent-admin:
    container_name: cogent-admin
    image: cogent/cogent-admin:v1.0
    volumes:
      - cogent-admin-data:/opt/cogent-admin/logs
      - cogent-admin-data:/opt/cogent-admin/config
      - cogent-admin-data:/opt/cogent-admin/uploadPath
      - cogent-admin-data:/opt/device-upgrade-pack-repo
    network_mode: "host"
    depends_on:
      - redis
      - mysql
  redis:
    image: cogent/redis:v1.0
    container_name: redis
    command: redis-server /etc/redis/redis.conf --appendonly yes
    volumes:
      - redis-data:/data #数据文件挂载
      - redis-data:/etc/redis
    network_mode: "host"
  mysql:
    container_name: mysql
    image: cogent/mysql:v1.0
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-time-zone='+08:00'
    restart: always
    environment:
      MYSQL_DATABASE: 'cogent-admin'
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - mysql-data:/var/lib/mysql #数据文件挂载
      - mysql-conf-data:/etc/mysql #配置文件挂载    记得设置时区,东八区
      - mysql-log-data:/var/log/mysql #日志文件挂载
    network_mode: "host"
  mediakit:
    image: zlmediakit/zlmediakit:Debug.latest
    container_name: mediakit
    volumes:
      - mediakit-data:/opt/media/bin/log
      - mediakit-data:/opt/media/conf/config.ini
    network_mode: "host"
  minio:
    image: quay.io/minio/minio
    container_name: minio
    command: server /data --console-address=":9090" --address=":9002" --ftp="address=:8021" --ftp="passive-port-range=30000-40000"
    environment:
      MINIO_ROOT_USER: ROOTNAME
      MINIO_ROOT_PASSWORD: CHANGEME123
      MINIO_NOTIFY_WEBHOOK_ENABLE_PRIMARY: "on"
      MINIO_NOTIFY_WEBHOOK_ENDPOINT_PRIMARY: "http://127.0.0.1:8080/buckets/event"
    volumes:
      - minio-data:/data
    network_mode: "host"

volumes:
  cogent-admin-data:
  mediakit-data:
  mysql-data:
  mysql-conf-data:
  mysql-log-data:
  redis-data:
  minio-data:

mysql的数据文件不能和日志文件等放到一起,否则启动时会报错,说数据目录已经有文件

对应用进行初始化

如果你有在初次部署时有对某些应用进行初始化的操作,比如我需要在初次部署时,将minio创建Access key,创建默认bucket,开启webhook。那么可以在minio容器启动后:

# check minio is running
if pgrep -x "minio" >/dev/null; then
	echo "minio init..."
	# minio deploy: create access key and secret key, create bucket, webhook event
	docker exec -i minio bash < minioDeploy.sh
else
	echo "minio is not running. This will influence file upload and download."
fi

这样会在容器中执行minioDeploy.sh脚本。

minioDeploy.sh脚本内容:

#!/bin/bash

# minio deploy: create access key and secret key, create bucket, webhook event
chmod +x /opt/bin/mc
cd /opt/bin || exit
mc alias set myminio http://127.0.0.1:9002 ROOTNAME CHANGEME123
mc admin user svcacct add --access-key "xFkEokGRAlwIs1234" --secret-key "jaz4FlvCDDKvbBuQYJ9NIohMUlRDsT132465789" myminio ROOTNAME
mc mb myminio/cogent
mc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event put
mc event add myminio/cogent arn:minio:sqs::PRIMARY:webhook --event delete

完整的部署脚本:

#!/bin/bash

echo "Please run this script as root. Because it will install docker and docker-compose.
If you have installed docker and docker-compose, please ignore this message.
And i use docker-compose version is 3.8, so please make sure your docker engine version is 19.03.0+."

echo

# check user is root
whoami=$(whoami)
if [ "$whoami" != "root" ]; then
	echo "Please run as root."
	exit 1
fi

# check docker is installed

# verlt 24.0.5 19.03.0 && echo "yes" || echo "no" # no
# this function check $1 is less than $2
versionLessThan() {
	if [ "$1" = "$2" ]; then
		return 1
	else
		# sort -V: natural sort of (version) numbers within text
		[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
	fi
}

if ! which docker >/dev/null 2>&1; then

	echo "docker is not installed. Start install docker."

	# install docker use offline package
	cd docker-install || exit

	sudo dpkg -i ./containerd.io_1.6.21-1_amd64.deb \
		./docker-ce_24.0.2-1~ubuntu.20.04~focal_amd64.deb \
		./docker-ce-cli_24.0.2-1~ubuntu.20.04~focal_amd64.deb \
		./docker-buildx-plugin_0.10.5-1~ubuntu.20.04~focal_amd64.deb \
		./docker-compose-plugin_2.18.1-1~ubuntu.20.04~focal_amd64.deb

	sudo service docker start

	cd ..
fi

echo "docker is installed."
# check docekr engine version
docker_version=$(docker version --format '{{.Server.Version}}')
echo "docker engine version is $docker_version"
# if docker_version less than 19.03.0, exit
if versionLessThan "$docker_version" "19.03.0"; then
	echo "docker engine version is less than 19.03.0, please upgrade docker engine."
	exit 1
fi

# laod images
docker load -i redis.tar
docker load -i mysql.tar
docker load -i mediakit.tar
docker load -i cogent-admin.tar
docker load -i minio.tar

# start docker containers
docker compose up -d redis mysql minio
docker compose up -d cogent-admin mediakit

# check minio is running
if pgrep -x "minio" >/dev/null; then
	echo "minio init..."
	# minio deploy: create access key and secret key, create bucket, webhook event
	docker exec -i minio bash < minioDeploy.sh
else
	echo "minio is not running. This will influence file upload and download."
fi

与离线部署-docker相似的内容:

离线部署-docker

离线部署 docker 关键词:docker离线部署,images离线安装,docker compose,shell,minio docker离线安装 docker install offline 下载相应的版本的deb包,我的系统是ubuntu20.04,因此选择focal文件夹,路径: 按照文档

windows离线部署VSCode在Centos7上的远程开发环境

前言 公司一直使用的是ssh+vim的远程开发方式,习惯了vim之后已经非常方便了。但是还是想尝试一下VSCode的开发方式。就我而言,原因如下 漂亮的语法高亮,并且有补全 基于语法解析的引用查找(尽管在我们项目的场景下还是一坨翔) Ctrl+Shift+F的快速搜索 可视化调试,可以直接在代码中下

手把手教你一套完善且高效的k8s离线部署方案

作者:郝建伟 背景 面对更多项目现场交付,偶而会遇到客户环境不具备公网条件,完全内网部署,这就需要有一套完善且高效的离线部署方案。 系统资源 | 编号 | 主机名称 | IP | 资源类型 | CPU | 内存 | 磁盘 | | -- | | | | | | | | 01 | k8s-master1

nginx+keepalived+pgsql+mysql+redis+tomcat离线部署过程

gcc pcre-devel openssl-devel zlib-devel离线安装包: [包含云盘地址.txt](https://codor.lanzoue.com/iAC7N0sj6vdi) 离线部署java+nginx+tomcat+pgsql+redis.zip: - 城通网盘: http

百度飞桨(PaddlePaddle) - PP-OCRv3 文字检测识别系统 Paddle Inference 模型推理(离线部署)

[百度飞桨(PaddlePaddle) - PP-OCRv3 文字检测识别系统 预测部署简介与总览](https://www.cnblogs.com/vipsoft/p/17439619.html) [百度飞桨(PaddlePaddle) - PP-OCRv3 文字检测识别系统 Paddle Inf

[转帖]tidb 搭建私有镜像库

https://docs.pingcap.com/zh/tidb/stable/tiup-mirror 在构建私有云时,通常会使用隔离的网络环境,此时无法访问 TiUP 的官方镜像。因此,TiUP 提供了构建私有镜像的方案,它主要由 mirror 指令来实现,该方案也可用于离线部署。使用私有镜像,你

[转帖]搭建私有镜像

https://docs.pingcap.com/zh/tidb/stable/tiup-mirror 在构建私有云时,通常会使用隔离的网络环境,此时无法访问 TiUP 的官方镜像。因此,TiUP 提供了构建私有镜像的方案,它主要由 mirror 指令来实现,该方案也可用于离线部署。使用私有镜像,你

[转帖]搭建私有镜像

https://docs.pingcap.com/zh/tidb/stable/tiup-mirror 在构建私有云时,通常会使用隔离的网络环境,此时无法访问 TiUP 的官方镜像。因此,TiUP 提供了构建私有镜像的方案,它主要由 mirror 指令来实现,该方案也可用于离线部署。使用私有镜像,你

一键启动的AI离线知识库,无需复杂环境依赖,小白都能上手了

简介 在人工智能技术飞速发展的今天,我们经常面临一个挑战:如何快速、简便地部署和使用AI技术?AntSK项目,一个开源的AI知识库和智能体,就是为了解决这一问题而诞生的。现在,我们自豪地宣布,AntSK已经实现了无需复杂部署的一键启动功能,让每个人都能轻松拥抱AI的便利。 为什么选择AntSK? 无

linux导出安装包

linux导出安装包 1 背景 部署企业内网环境,主机无法连通外网.不能直接使用yum install安装程序.针对此种情况有如下两个安装办法 源码安装(需要编译环境,安装复杂,容易出错,不推荐) 使用rpm离线安装(需要离线安装包,简单,推荐) 2 依赖 linux安装包多数有依赖关系,在导出离线