利用docker容器运行.net core webapi
利用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的更多相关文章
- Docker容器运行ASP.NET Core
最近要学习的知识太多,都不知道先学哪些了,原本计划这篇博客是写xamarin.forms中的listview用法,关于listview的用法简书上有一篇介绍的也比较详细,所以暂时先缓一缓,属于次要任务 ...
- 基于阿里云容器服务用docker容器运行ASP.NET 5示例程序
小试阿里云容器服务 之后,接下来有一个挡不住的小试冲动--用docker容器运行程序.首先想到的程序是 ASP.NET 5示例程序,于是参考msdn博客中的这篇博文 Running ASP.NET 5 ...
- Docker 为 ASP.NET Core WebApi 应用程序生成 Docker 映像,创建容器并运行
1.使用VS2017新建ASP.NET Core WebApi项目 选择API启用Docker支持 2.为 ASP.NET Core WebApi 应用程序生成 Docker 映像,并创建容器运行 生 ...
- .Net Core 自动化部署:使用jenkins部署到linux docker容器运行
上次我们说到.Net Core 自动化部署:使用docker版jenkins部署dotnetcore应用,这次我们使用jenkins发布我们的.NET Core站点到docker容器中运行,为后面的的 ...
- docker容器互联 (.net core容器,mysql容器)
背景 有两个容器一个运行的.net core的项目 另一个运行的mysql的数据 并且这两个容器在同一个机子上(或者局域网),那么理论上.net core的项目去访问mysql是可以走内网的 但是容器 ...
- docker (2)---存储、网络(利用docker容器上线静态网站)
一.docker底层依赖的核心技术 1.命名空间 (Namespaces) 2.控制组 (Control Groups) 3.联合文件系统 (Union File System) 4.Linux 虚拟 ...
- Docker教程:使用Docker容器运行Nginx并实现反向代理
一.前言 我们知道,为了安全考虑,我们一般会设置反向代理,用来屏蔽应用程序真实的IP和端口号.在Linux系统上最常用的反向代理就是Nginx.本篇文章中,我们会通过Docker容器分别运行一个Ngi ...
- 浩若烟海事半功倍|利用Docker容器技术构建自动化分布式web测试集群Selenium Grid
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_195 "世界上有那么多城市,城市里有那么多的酒馆,可她,却偏偏走进了我的-",这是电影<卡萨布拉卡> ...
- docker容器运行后退出,怎么才能一直运行?【转】
现象 启动docker容器 docker run –name [CONTAINER_NAME] [CONTAINER_ID] 查看容器运行状态 docker ps -a 发现刚刚启动的mydocker ...
随机推荐
- Cython保护Python代码
注:.pyc也有一定的保护性,容易被反编译出源码... 项目发布时,为防止源码泄露,需要对源码进行一定的保护机制,本文使用Cython将.py文件转为.so进行保护.这一方法,虽仍能被反编译,但难度会 ...
- Java练习 SDUT-2174_回文时间
回文时间 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description HH 每天都会熬夜写代码,然后很晚才睡觉,但是每天早晨六点多必 ...
- Namenode文件系统命名空间映像文件及修改日志
- TensorFlow 池化层
在 TensorFlow 中使用池化层 在下面的练习中,你需要设定池化层的大小,strides,以及相应的 padding.你可以参考 tf.nn.max_pool().Padding 与卷积 pad ...
- HZOJ visit
对于前30%的数据,可以考虑dp,f[i][j][k]表示时间为i,在i,j位置的方案数,枚举转移即可.要注意的是可以走到矩阵外. 对于另外30%数据,考虑推一下式子,设向右走y步,左z,上s,下x. ...
- iOS学习--详解UIView的 contentStretch属性
通过实例和图片理解UIView的contentStretch属性 方法 通过一个图片建立一个简单的UIImageView 设置它的contentStretch属性 修改它的frame属性 观察 测试用 ...
- ubuntu 运行级别initlevel
Linux 系统任何时候都运行在一个指定的运行级上,并且不同的运行级的程序和服务都不同,所要完成的工作和要达到的目的都不同,系统可以在这些运行级之间进行切换,以完成不同的工作.Ubuntu 的系统运行 ...
- springboot2.04与activiti 6.0集成
本文就不对activiti做解释,下面直接看项目集成 以下顺序方面根据我的理解来,可以先从第二章看,再看第一张与第三章 增加activiti表的API,备注用. 目录 一.springboot2.X集 ...
- Java反射机制(四):动态代理
一.静态代理 在开始去学习反射实现的动态代理前,我们先需要了解代理设计模式,那何为代理呢? 代理模式: 为其他对象提供一种代理,以控制对这个对象的访问. 先看一张代理模式的结构图: 简单的理解代理设计 ...
- PL/SQL语言的学习笔记
一.PL/SQL简介1.什么是PL/SQL程序?(PL/SQL是对SQL语言的一个扩展,从而形成的一个语言) 2.PL/SQL语言的特点(操作Orcale数据库效率最高的就是PL/SQL语言,而不是C ...