3

ASP.NET Web 应用 Docker踩坑历程 - 毛毛虫

 2 years ago
source link: https://www.cnblogs.com/catzhou/p/16194431.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ASP.NET Web 应用 Docker踩坑历程

听说Docker这玩意挺长时间了,新建Web应用的时候,也注意到有个启用Docker的选项。
前两天扫了一眼《【大话云原生】煮饺子与docker、kubernetes之间的关系》,觉得有点意思,决定试试Docker。
然后被坑、百度...
现将整个过程记录一下

一、新建项目

点击创建,被通知“需要安装Docker Desktop”,于是下载、安装、按要求重启电脑。

运行Docker Desktop,被通知“需要安装WSL 2”,于是又下载、安装。

二、运行项目

按 F5 运行项目,vs停在 Info: C:\Users\catzhou\vsdbg\vs2017u5 exists, deleting.不动了。

百度到《visual studio 容器工具首次加载太慢 vsdbg\vs2017u5 exists, deleting 的解决方案》这篇文章,依葫芦画瓢搞定。

再次 F5,成果如下:

吐槽一下:下载vsdbug的两个包速度实在太慢了(为此特意安装了迅雷),然后创建文件夹、4个文本文件颇不容易。俺把vs2017u5打了个包(版本是:17.0.10712.2),你直接下载解压到vsdbg即可。

三、发布到Docker Hub

  1. Docker Hub注册了一个用户

  2. Docker Desktop登录
    登陆后

    变成了

  3. 发布


    点击发布,成果如下:

四、部署到 阿里云-轻量应用服务器-Docker应用镜像

花了60元人民币,买了一个月的Docker应用镜像服务器

  1. 远程连接到服务器

  2. 切换到root账号
    sudo su root

  3. 拉取镜像
    docker pull catzhou2021/webapp1

  4. 查看镜像
    docker images

  5. 创建容器c1并后台运行
    docker run --name=c1 -p 12345:80 -d catzhou2021/webapp1

  6. 查看是否正常运行
    curl http://localhost:12345

  7. 设置防火墙-添加规则

  8. 浏览器访问

如此,大功告成。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK