PowerShell install Docker+docker-compoer

2023-05-16

See the source image

docker 前言

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。

docker-compose 

Compose 是用于定义和运行多容器 Docker 应用程序的工具。 使用 Compose,您可以使用 YAML 文件来配置应用程序的服务。 然后,使用单个命令创建并启动所有服务 从您的配置中。

docker 参考

dockerdocker-composewlspowershell
downloaddownload参考参考

前提条件

  • 开启wmi,配置网卡,参考 

安装 docker,docker_compose

  • 创建安装自动化脚本

  • 实现在线安装docker,docker_compose,安装hayper-v,环境变量,系统服务,防火墙配置,企业微信机器人通,,开机自启动Hyper-v,安装完成需要重启系统哦因为Hyper-v的原因脚本执行完成会自动重启Restart-Computer,有业务运行把脚本内的Restart-Computer去除。
  • Start-Service Docker #启动docker,默认开机自启动

  • docker pull mcr.microsoft.com/windows/servercore:ltsc2019 # 下载docker images

  • docker pull mcr.microsoft.com/dotnet/framework/sdk:3.5-windowsservercore-ltsc2019 #容器项目需要.net的支持

  • $webhook = 企业微信机器人地址

  • C:\Program Files\docker  #安装目录位置

  • C:\ProgramData\docker #数据缓存位置,此处是docker 启动后生成的目录

  • 以下脚本实现在Windows Server 2019 

  • 需要将主机,PC,服务器Bios或者UEFI下开启CPU虚拟化技术

powershell-install-docker.ps1

<# Powershell Install docker
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+  _____                       _____ _          _ _ +
+ |  __ \                     / ____| |        | | |+
+ | |__) |____      _____ _ _| (___ | |__   ___| | |+
+ |  ___/ _ \ \ /\ / / _ \ '__\___ \| '_ \ / _ \ | |+
+ | |  | (_) \ V  V /  __/ |  ____) | | | |  __/ | |+
+ |_|   \___/ \_/\_/ \___|_| |_____/|_| |_|\___|_|_|+
+ +++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                                                              
# Powershell Install docker
# .\powershell-install-docker.ps1
#> 

$drive="c:\"
$docker_url="https://download.docker.com/win/static/stable/x86_64/"
$docker_zip="docker-23.0.3.zip"
$docker_site="C:\Program Files\"

$docker_compose_url="https://github.com/docker/compose/releases/download/v2.17.2/"
$docker_compose_exe="docker-compose-windows-x86_64.exe"

Write-Host "install Hyper-V & Containers" -ForegroundColor Green
Install-WindowsFeature -Name Hyper-V,Containers -IncludeManagementTools -Restart:$false

Write-Host "check Hyper-V & Containers " -ForegroundColor Green
Get-WindowsFeature *Hyper-V*,*Container*

Write-Host "Set the system to start the Hypervisor" -ForegroundColor Green
bcdedit /set hypervisorlaunchtype auto

Write-Host "Enable the Windows subsystem for Linux" -ForegroundColor Green
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -all -NoRestart

Write-Host "Enable WSL2" -ForegroundColor Green
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -all -NoRestart

Write-Host "download docker" -ForegroundColor Green
wget -Uri $docker_url$docker_zip -UseBasicParsing -OutFile $drive$docker_zip

Write-Host "download docker" -ForegroundColor Green
wget -Uri $docker_compose_url$docker_compose_exe -UseBasicParsing -OutFile $drive$docker_compose_exe

Write-Host "decompression docker" -ForegroundColor Green
Expand-Archive -Path $drive\$docker_zip -DestinationPath $docker_site

Write-Host "Rename docker-compoer" -ForegroundColor Green
Rename-Item $drive$docker_compose_exe "docker-compose.exe"

Write-Host "Move docker-compoer up docker" -ForegroundColor Green
Move-Item $drive\docker-compose.exe $docker_site\docker

Write-Host "Create docker environment variables" -ForegroundColor Green
$env:path += ";C:\Program Files\docker"
setx PATH $env:path /M

Write-Host "Create a Docker system service" -ForegroundColor Green
New-Service -Name Docker -BinaryPathName "C:\Program Files\docker\dockerd.exe --run-service --experimental=true" -DisplayName "Docker Engine" -Description "Docker Engine - Enterprise Edition"

Write-Host "docker version check" -ForegroundColor Green
docker --version

Write-Host "docker version check" -ForegroundColor Green
docker-compose.exe --version

Write-Host "Add Docker service to firewall allowed list" -ForegroundColor Green
New-NetFirewallRule -DisplayName "Docker engine" -Direction Inbound -Protocol TCP -LocalPort 2376 -Action Allow

Write-Host "delete docker software package" -ForegroundColor Green
Remove-Item $drive$docker_zip -recurse -force -verbose

#Enterprise wechat robot address
$webhook = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXX"

#Obtain the Windows host system version
$Win_version = Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty Caption
$Win_version_Names = echo $Win_version

#docker-compose version
$docker_compose_version =  docker-compose.exe -v

#docker version
$docker_version = (Get-Item "C:\Program Files\docker\docker.exe").VersionInfo.FileVersion

$content = Write-Output ""Win_version: $Win_version_Names" `n "docker_compose_version: $docker_compose_version" `n "docker_version: $docker_version""

$body = "{
    `"msgtype`":`"text`",
    `"text`":{
    `"content`":`"$content`",
	`"mentioned_list`":[`"jason`"]
    }
}"

Write-Host "The variable value obtained is transferred to the enterprise wechat robot" -ForegroundColor Green
Invoke-RestMethod $webhook -ContentType "application/json;charset=utf-8" -Method Post -Body $body

Write-Host "reboot system" -ForegroundColor Green
Restart-Computer

 执行安装,下载慢的化,手动下载下来在进行部署,注释wget部分

.\powershell-install-docker.ps1

企业微信机器人通知

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PowerShell install Docker+docker-compoer 的相关文章

随机推荐

  • 【Matlab】滤波器设计中的频率归一化

    信号处理工具箱中 xff0c 归一化频率为把幅频响应 xff08 或其他 xff09 曲线的横轴单位从Hz变为rad sample 经常使用的频率是Nyquist频率 xff0c 它被定义为采样频率的一半 不考虑镜像部分范围 xff1a 0
  • Ubuntu16.04中Displays点不开、Language Support点不开、fcitx安装失败的解决方法

    Ubuntu中Displays点不开的解决方法 问题 由于Ubuntu中Displays打不开导致分辨率不能改 xff0c 只能小屏幕 xff0c 怎么样才能修复 xff0c 让Displays能设置 xff1f 解决方法 在终端输入 xf
  • makefile:2: *** missing separator. Stop. make 之后出现的错误,解决方法

    问题 今天建立了个个helloworld c 以及Makefile文件 hellworld c 中内容如下 span class hljs preprocessor include lt stdio h gt span span class
  • 四旋翼无人机俯仰角、横滚校和航向角和电机输出PWM的关系详解(一种情况)

    说明 xff1a 陀螺仪和加速度计摆放坐标如下 xff1a 机头方向可以任意设置 xff0c 如图所示 X 型和十字型无人机的机头方向 由于电机转动会产生一个扭力 xff0c 故相邻的两个电机转动方向相反 在实际实验中 xff0c 当姿态角
  • [docker]Sealer简介

    文章目录 安装创建集群清理集群本机免密登录 镜像构建与运行KubefileSealer ImageClusterfile 制作app镜像 sealer是阿里开源的一款分布式应用打包交付运行的解决方案 xff1b 通过把分布式应用及其所依赖的
  • APM EKF2 alt source

    主要看NavEKF2 core下面的selectHeightForFusion 函数 首先从应用层读取高度 xff0c 再进行角度补偿 xff0c 分别有三种高度源 xff1a baro rangefinder GPS xff08 可以在地
  • zsh: command not found ??? 所有命令在zsh终端失效

    多增加几个环境变量路径即可 在 zshrc 最底部加入即可 xff1a PATH 61 bin usr bin usr local bin PATH export PATH
  • MISSION_MAVLINK

    上传航点的mavlink包 MISSION ITEM 39 Message encoding a mission item This message is emitted to announce the presence of a miss
  • VS2017使用libcurl,链接错误

    当使用libcurl库出现链接错误 xff0c 如下 1 gt WebSocketMsg obj error LNK2001 unresolved external symbol imp curl global init 1 gt WebS
  • Linux Shell 实现一键部署Msql8

    mysql前言 MySQL 是最流行的关系型数据库管理系统 xff0c 在 WEB 应用方面 MySQL 是最好的 RDBMS Relational Database Management System xff1a 关系数据库管理系统 应用
  • Linux Shell 实现一键部署Msql5

    mysql前言 MySQL 是最流行的关系型数据库管理系统 xff0c 在 WEB 应用方面 MySQL 是最好的 RDBMS Relational Database Management System xff1a 关系数据库管理系统 应用
  • Linux Shell 实现一键部署tomcat10+java13

    tomcat 前言 Tomcat 服务器是一个免费的开放源代码的Web 应用服务器 xff0c 属于轻量级应用服务器 xff0c 在中小型系统和并发访问用户不是很多的场合下被普遍使用 xff0c 是开发和调试JSP 程序的首选 对于一个初学
  • Linux Shell 实现一键部署SQL_Server2022

    sql Server 前言 Microsoft SQL Server 是一个全面的数据库平台 xff0c 使用集成的商业智能 BI 工具提供了企业级的数据管理 Microsoft SQL Server 数据库引擎为关系型数据和结构化数据提供
  • Linux Shell 实现一键部署Redis6

    redis 前言 Redis xff08 Remote Dictionary Server xff0c 即远程字典服务 xff0c 是一个开源的使用ANSI C语言编写 支持网络 可基于内存亦可持久化的日志型 Key Value数据库 xf
  • Linux Shell 实现一键部署Rabbitmq

    rabbitmq 前言 RabbitMQ是实现了高级消息队列协议 xff08 AMQP xff09 的开源消息代理软件 xff08 亦称面向消息的中间件 xff09 RabbitMQ服务器是用Erlang语言编写的 xff0c 而集群和故障
  • [linux]mount与nfs挂载简介

    文章目录 挂载mount目录间挂载卸载与fuserfstabNFS Server配置命令 NFS client mount用于挂载设备 xff1a 挂载分区 xff1a mount dev sdb1 data xff1b 文件夹间 xff1
  • Linux Shell 实现一键部署Nginx

    nginx前言 nginx engine x 是 HTTP 和反向代理服务器 邮件代理服务器和通用 TCP UDP 代理服务器 xff0c 最初由Igor Sysoev编写 很长一段时间以来 xff0c 它一直在许多负载重的俄罗斯网站上运行
  • Linux Shell 实现一键部署二进制Rabbitmq

    rabbitmq 前言 RabbitMQ是实现了高级消息队列协议 xff08 AMQP xff09 的开源消息代理软件 xff08 亦称面向消息的中间件 xff09 RabbitMQ服务器是用Erlang语言编写的 xff0c 而集群和故障
  • Linux Shell 实现一键部署二进制docker+docker_compose

    docker 前言 Docker 是一个开源的应用容器引擎 xff0c 让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中 xff0c 然后发布到任何流行的 Linux或Windows 机器上 xff0c 也可以实现虚拟化 容器是完全
  • PowerShell install Docker+docker-compoer

    docker 前言 Docker 是一个开源的应用容器引擎 xff0c 让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中 xff0c 然后发布到任何流行的 Linux或Windows 机器上 xff0c 也可以实现虚拟化 容器是完全