利用docker容器运行.net core webapi

:first-child {
margin-top: 0 !important;
}

> :last-child {
margin-bottom: 0 !important;
}

a:not([href]) {
color: inherit;
text-decoration: none;
}

blockquote,
dl,
ol,
p,
pre,
table,
ul {
margin-bottom: 16px;
margin-top: 0;
}

hr {
background-color: #e1e4e8;
border: 0;
height: 0.25em;
margin: 24px 0;
padding: 0;
}

blockquote {
border-left: 0.25em solid #dfe2e5;
color: #6a737d;
padding: 0 1em;
}

blockquote > :first-child {
margin-top: 0;
}

blockquote > :last-child {
margin-bottom: 0;
}

kbd {
background-color: #fafbfc;
border: 1px solid #c6cbd1;
border-bottom-color: #959da5;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #959da5;
color: #444d56;
display: inline-block;
font-size: 11px;
line-height: 10px;
padding: 3px 5px;
vertical-align: middle;
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 600;
line-height: 1.25;
margin-bottom: 16px;
margin-top: 24px;
}

h1 {
font-size: 2em;
}

h1,
h2 {
border-bottom: 1px solid #eaecef;
padding-bottom: 0.3em;
}

h2 {
font-size: 1.5em;
}

h3 {
font-size: 1.25em;
}

h4 {
font-size: 1em;
}

h5 {
font-size: 0.875em;
}

h6 {
color: #6a737d;
font-size: 0.85em;
}

ol,
ul {
padding-left: 2em;
}

ol ol,
ol ul,
ul ol,
ul ul {
margin-bottom: 0;
margin-top: 0;
}

li {
word-wrap: break-all;
}

li > p {
margin-top: 16px;
}

li + li {
margin-top: 0.25em;
}

dl {
padding: 0;
}

dl dt {
font-size: 1em;
font-style: italic;
font-weight: 600;
margin-top: 16px;
padding: 0;
}

dl dd {
margin-bottom: 16px;
padding: 0 16px;
}

table {
display: block;
overflow: auto;
width: 100%;
}

table th {
font-weight: 600;
}

table td,
table th {
border: 1px solid #dfe2e5;
padding: 6px 13px;
}

table tr {
background-color: #fff;
border-top: 1px solid #c6cbd1;
}

table tr:nth-child(2n) {
background-color: #f6f8fa;
}

img {
background-color: #fff;
box-sizing: content-box;
max-width: 100%;
}

img[align='right'] {
padding-left: 20px;
}

img[align='left'] {
padding-right: 20px;
}

code {
background-color: rgba(27, 31, 35, 0.05);
border-radius: 3px;
font-size: 85%;
margin: 0;
padding: 0.2em 0.4em;
}

pre {
word-wrap: normal;
}

pre > code {
background: transparent;
border: 0;
font-size: 100%;
margin: 0;
padding: 0;
white-space: pre;
word-break: normal;
}

.highlight {
margin-bottom: 16px;
}

.highlight pre {
margin-bottom: 0;
word-break: normal;
}

.highlight pre,
pre {
background-color: #f6f8fa;
border-radius: 3px;
font-size: 85%;
line-height: 1.45;
overflow: auto;
padding: 16px;
}

pre code {
background-color: transparent;
border: 0;
display: inline;
line-height: inherit;
margin: 0;
max-width: auto;
overflow: visible;
padding: 0;
word-wrap: normal;
}

kbd {
background-color: #fafbfc;
border: 1px solid #d1d5da;
border-bottom-color: #c6cbd1;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #c6cbd1;
color: #444d56;
display: inline-block;
font: 11px SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier,
monospace;
line-height: 10px;
padding: 3px 5px;
vertical-align: middle;
}

:checked + .radio-label {
border-color: #0366d6;
position: relative;
z-index: 1;
}

.task-list-item {
list-style-type: none;
}

.task-list-item + .task-list-item {
margin-top: 3px;
}

.task-list-item input {
margin: 0 0.2em 0.25em -1.6em;
vertical-align: middle;
}

hr {
border-bottom-color: #eee;
}
-->

docker常用命令

  • docker info|查询docker基本信息
  • docker images | 查看所有镜像
  • docker ps | 查询所有容器
  • docker rmi | Remove one or more images
  • docker rm | Remove one or more containers
  • docker build | Build an image from a Dockerfile
  • docker run | Run a command in a new container
  • docker stop | Stop one or more running containers
  • docker start | Start one or more stopped containers
  • docker pull | Pull an image or a repository from a registry

cmd创建项目

安装.net core sdk

查询是否安装成功

C:\Users\jiangyi\myproj>dotnet -version

Unknown option: -version

.NET Core SDK (3.0.100)

新建项目

C:\Users\jiangyi>dotnet new webapi -n myproj

The template "ASP.NET Core Web API" was created successfully.

Processing post-creation actions...

Running 'dotnet restore' on myproj\myproj.csproj...

C:\Users\jiangyi\myproj\myproj.csproj 的还原在 88.66 ms 内完成。

Restore succeeded.

生成项目

cd到项目目录:

C:\Users\jiangyi>cd myproj

编译生成项目:

C:\Users\jiangyi\myproj>dotnet restore

C:\Users\jiangyi\myproj\myproj.csproj 的还原在 30.56 ms 内完成。

在本地运行

C:\Users\jiangyi\myproj>dotnet run

info: Microsoft.Hosting.Lifetime[0]

  Now listening on: https://localhost:5001

info: Microsoft.Hosting.Lifetime[0]

  Now listening on: http://localhost:5000

info: Microsoft.Hosting.Lifetime[0]

  Application started. Press Ctrl+C to shut down.

可以通过浏览器访问https://localhost:5001

创建镜像

ps:myprojimage为你要输出的镜像名称,后面有'.'注意

C:\Users\jiangyi\myproj>docker build -t myprojimage .

...

Build succeeded. 0 Warning(s) 0 Error(s)

Time Elapsed 00:00:03.15

发布项目

ps:运行镜像,将docker的80端口发布出去,在外部访问使用8080端口

C:\Users\jiangyi\myproj>docker run -p 8080:80 myprojimage

info: Microsoft.Hosting.Lifetime[0]

  Now listening on: http://[::]:80

info: Microsoft.Hosting.Lifetime[0]

  Application started. Press Ctrl+C to shut down.

ps:如没有DockerFile文件,可以使用vs打开项目添加docker支持后就有DockerFile文件了。

利用docker容器运行.net core webapi的更多相关文章

  1. Docker容器运行ASP.NET Core

    最近要学习的知识太多,都不知道先学哪些了,原本计划这篇博客是写xamarin.forms中的listview用法,关于listview的用法简书上有一篇介绍的也比较详细,所以暂时先缓一缓,属于次要任务 ...

  2. 基于阿里云容器服务用docker容器运行ASP.NET 5示例程序

    小试阿里云容器服务 之后,接下来有一个挡不住的小试冲动--用docker容器运行程序.首先想到的程序是 ASP.NET 5示例程序,于是参考msdn博客中的这篇博文 Running ASP.NET 5 ...

  3. Docker 为 ASP.NET Core WebApi 应用程序生成 Docker 映像,创建容器并运行

    1.使用VS2017新建ASP.NET Core WebApi项目 选择API启用Docker支持 2.为 ASP.NET Core WebApi 应用程序生成 Docker 映像,并创建容器运行 生 ...

  4. .Net Core 自动化部署:使用jenkins部署到linux docker容器运行

    上次我们说到.Net Core 自动化部署:使用docker版jenkins部署dotnetcore应用,这次我们使用jenkins发布我们的.NET Core站点到docker容器中运行,为后面的的 ...

  5. docker容器互联 (.net core容器,mysql容器)

    背景 有两个容器一个运行的.net core的项目 另一个运行的mysql的数据 并且这两个容器在同一个机子上(或者局域网),那么理论上.net core的项目去访问mysql是可以走内网的 但是容器 ...

  6. docker (2)---存储、网络(利用docker容器上线静态网站)

    一.docker底层依赖的核心技术 1.命名空间 (Namespaces) 2.控制组 (Control Groups) 3.联合文件系统 (Union File System) 4.Linux 虚拟 ...

  7. Docker教程:使用Docker容器运行Nginx并实现反向代理

    一.前言 我们知道,为了安全考虑,我们一般会设置反向代理,用来屏蔽应用程序真实的IP和端口号.在Linux系统上最常用的反向代理就是Nginx.本篇文章中,我们会通过Docker容器分别运行一个Ngi ...

  8. 浩若烟海事半功倍|利用Docker容器技术构建自动化分布式web测试集群Selenium Grid

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_195 "世界上有那么多城市,城市里有那么多的酒馆,可她,却偏偏走进了我的-",这是电影<卡萨布拉卡> ...

  9. docker容器运行后退出,怎么才能一直运行?【转】

    现象 启动docker容器 docker run –name [CONTAINER_NAME] [CONTAINER_ID] 查看容器运行状态 docker ps -a 发现刚刚启动的mydocker ...

随机推荐

  1. CSS Specificity

    CSS的specificity特性或称非凡性,它是一个衡量CSS值优先级的一个标准. 其实就是解决冲突,当同一个元素被CSS选择符选中,按照优先权取舍不同的CSS规则. specificity用一个四 ...

  2. vue中$bus的传参的坑

    今天在做项目的时候碰见一个坑就是B页面有个点击事件需要触发完然后跳转到A页面,接着页面跳转过去后再A页面的create生命周期中利用on监听事件的改变,接着赋值给data里面某个数据,但是奇怪的问题是 ...

  3. poj 3107 Godfather 求树的重心【树形dp】

    poj 3107 Godfather 和poj 1655差不多,那道会了这个也就差不多了. 题意:从小到大输出树的重心. 题会卡stl,要用邻接表存树..... #include<iostrea ...

  4. Python中的生成器(generator)

    生成器: 在函数内部包含yield关键字,那么该函数执行的结果就是生成器(生成器即是迭代器) yield的功能:1.把函数的执行结果做成迭代器(帮函数封装好__iter__(),__next__()方 ...

  5. SDUT-3334_数据结构实验之栈与队列七:出栈序列判定

    数据结构实验之栈与队列七:出栈序列判定 Time Limit: 30 ms Memory Limit: 1000 KiB Problem Description 给一个初始的入栈序列,其次序即为元素的 ...

  6. LOJ6079「2017 山东一轮集训 Day7」养猫

    养ImmortalCO k可重区间问题 的增强版:有上下界! 直接都选择s[i],然后再把一些调整到e[i] 考虑通过最大流的“最大”,使得至少每k个有me个e, 通过最大流的“上界”,限制每k个最多 ...

  7. 6、mysql的安装

    1.安装mysql-Server,并输入root密码 sudo apt-get install mysql-server 2.安装mysql客户端 sudo apt-get install mysql ...

  8. Vue中computed与method的区别

    转载于:https://segmentfault.com/a/1190000014478664?utm_source=tag-newest 1.computed区别于method的两个核心 在官方文档 ...

  9. Python--day41--threading中的定时器Timer

    定时器Timer:定时开启线程 代码示例: #定时开启线程 import time from threading import Timer def func(): print('时间同步') #1-3 ...

  10. React MVC框架 <某某后台商品管理开源项目> 完成项目总结

    **百货后台商品信息开源项目 1.利用React  app脚手架 2.封装打包 buid 3.更偏向于后台程序员开发思维 4.利用的 react -redux    react-router-dom  ...