windows下安装docker并部署应用的极简记录

1下载docker

下载地址:https://www.docker.com/products/docker-desktop/
选择windows版下载

2 安装前检查

我的系统为windows10家庭版
检查hyper-v是否打开:
在这里插入图片描述

找不到hyper-v的话以管理员身份运行下面bat,脚本内容:

pushd "%~dp0"
 
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
 
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
 
del hyper-v.txt
 
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL

3 安装docker

点击Docker Desktop Installer.exe安装即可
在设置里添加镜像地址:

 "registry-mirrors": [
    "https://1nj0zren.mirror.aliyuncs.com",
    "https://docker.mirrors.ustc.edu.cn",
    "http://f1361db2.m.daocloud.io",
    "https://registry.docker-cn.com"
  ]

4 安装wsl

(Windows Subsystem for Linux)
下载安装参考:https://learn.microsoft.com/zh-cn/windows/wsl/
以系统管理员的身份安装wsl_update_x64.msi。
打开windows的powershell,运行如下命令:wsl --set-default-version 2
安装完需重启电脑

5 部署demo应用,以springboot为例

5.1

将demo.jar包和DockerFile放在同一个文件夹下,,用cmd进入当前位置下执行后面的命令。
DockerFile内容:

FROM openjdk:8-jdk-alpine
ADD demo-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]

5.2拉取openjdk

docker pull openjdk:8-jdk-alpine

5.3 构建镜像

 docker build -t test .

5.4 运行镜像

docker run -p 8080:8080 -d demo

5.5 在Docker Desktop上可以看到容器已启动

在这里插入图片描述

Docker on Windows by Elton Stoneman English | 14 July 2017 | ISBN: 1785281658 | 358 Pages | AZW3/EPUB/MOBI/PDF (conv) | 23.77 MB Key Features Start building applications as Docker images and running containers in a Windows production environment Design and implement distributed applications that run across multiple networked containers Build a full Continuous Deployment pipeline for a .NET Core application running on Windows Book Description Docker has become hugely popular because it offers benefits at all stages of software design and delivery. Until recently, it was impossible to use a Windows Server platform to host the Docker Engine without adding an additional layer of virtualization. Starting with Windows Server 2016, you are able to use Docker on Windows and take advantage to easily build, deploy, and run Windows Containers. From building and running simple images to designing and implementing distributed applications, this book will teach everything you need to know while using Docker on Windows. You will start by installing Docker on different versions of Windows and Windows Server, and run a simple container to verify that the setup is working correctly. You will see how to build Docker images with a Dockerfile for a simple website, and then run it on Windows. Moving on, we'll cover the practical usage of Docker and the tools in the Docker ecosystem, such as Docker Compose, Docker Trusted Registry, and Docker Swarm Mode. Then, you'll be able to apply that knowledge by building a full continuous deployment pipeline for a .NET Core application running on Windows. We'll also dive deep into some of the core features of Docker, such as networking and security. At the end of the book, you'll be guided through a business case that will help you practically implement Docker in a real-world scenario. What you will learn Understand how Docker works, build images, and run containers Run Docker on different versions of Windows, and on the cloud with Azure Des
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值