File tree Expand file tree Collapse file tree 4 files changed +52
-4
lines changed Expand file tree Collapse file tree 4 files changed +52
-4
lines changed Original file line number Diff line number Diff line change 1
- # See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
1
+ FROM centos:7 AS base
2
+
3
+ # Add Microsoft package repository and install ASP.NET Core
4
+ RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm \
5
+ && yum install -y aspnetcore-runtime-6.0
6
+
7
+ # Ensure we listen on any IP Address
8
+ ENV DOTNET_URLS=http://+:3000
2
9
3
- FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
4
10
WORKDIR /app
5
- EXPOSE 80
6
- EXPOSE 443
7
11
12
+ # ... remainder of dockerfile as before
8
13
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
9
14
WORKDIR /src
10
15
COPY ["CacheSample.WebApi/CacheSample.WebApi.csproj" , "CacheSample.WebApi/" ]
Original file line number Diff line number Diff line change 1
1
# ASP.NET Core (.NET 6) Web API with cache
2
2
3
+ To run this project from Docker
4
+
5
+ ``` sh
6
+ $> docker build -t aspnet-core-net-6-api-cache -f ./CacheSample.WebApi/Dockerfile .
7
+ $> docker create --name aspnet-core-net-6-api-cache-core aspnet-core-net-6-api-cache
8
+ $> docker start aspnet-core-net-6-api-cache-core
9
+ $> docker run --rm -p 3000:3000 aspnet-core-net-6-api-cache
10
+ ```
11
+
12
+ Solution sample to (port is already allocated)
13
+ ```
14
+ Bind for 0.0.0.0:3000 failed: port is already allocated.
15
+
16
+ $> docker ps
17
+
18
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
19
+ 69e65c95dfaf aspnet-core-net-6-api-cache "dotnet CacheSample.…" 35 seconds ago Up 29 seconds aspnet-core-net-6-api-cache-core
20
+
21
+ $> docker stop 69e65c95dfaf
22
+
23
+ $> docker ps
24
+
25
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
26
+
27
+ $> docker run --rm -p 3000:3000 aspnet-core-net-6-api-cache
28
+ info: Microsoft.Hosting.Lifetime[14]
29
+ Now listening on: http://[::]:3000
30
+ info: Microsoft.Hosting.Lifetime[0]
31
+ Application started. Press Ctrl+C to shut down.
32
+ info: Microsoft.Hosting.Lifetime[0]
33
+ Hosting environment: Production
34
+ info: Microsoft.Hosting.Lifetime[0]
35
+ Content root path: /app/
36
+ ```
37
+
3
38
#### Using Memory
4
39
![ image] ( https://user-images.githubusercontent.com/22874642/177662412-5d5e270c-09bf-4024-9a21-4df086c20e8b.png )
5
40
Original file line number Diff line number Diff line change
1
+ docker build -t aspnet-core-net-6-api-cache -f ./CacheSample.WebApi/Dockerfile .
2
+ docker create --name aspnet-core-net-6-api-cache-core aspnet-core-net-6-api-cache
3
+ docker start aspnet-core-net-6-api-cache-core
4
+ docker run --rm -p 3000:3000 aspnet-core-net-6-api-cache
Original file line number Diff line number Diff line change
1
+ docker build -t aspnet-core-net-6-api-cache -f ./CacheSample.WebApi/Dockerfile .
2
+ docker create --name aspnet-core-net-6-api-cache-core aspnet-core-net-6-api-cache
3
+ docker start aspnet-core-net-6-api-cache-core
4
+ docker run --rm -p 3000:3000 aspnet-core-net-6-api-cache
You can’t perform that action at this time.
0 commit comments