gpt4 book ai didi

docker - docker-compose无法连接到asp.net核心站点

转载 作者:行者123 更新时间:2023-12-02 20:05:02 24 4
gpt4 key购买 nike

我正在尝试根据Windows Server 2016上的https://docs.docker.com/get-started/part3为ASP.NET Core应用程序运行docker-compose。

Docker文件

FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app
EXPOSE 80

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Community.dll"]

docker-compose.yml
version: "3"
services:
web:
image: linuxchata/community-app:v1
deploy:
replicas: 1
resources:
limits:
memory: 500M
restart_policy:
condition: on-failure
ports:
- "80:4000"
networks:
- webnet
networks:
webnet:

通过运行以下命令已创建服务
docker stack deploy -c docker-compose.yml community

docker service ls命令
ID                  NAME                MODE                REPLICAS            IMAGE                         PORTS
t5jsy98xkl5p community_web replicated 1/1 linuxchata/community-app:v1 *:80->4000/tcp

http://127.0.0.1:4000/http://localhost:4000/http://servername:4000/无法通过浏览器使用。但是,运行单个容器按预期运行(通过docker run命令)。

您能告诉我这里可能是个问题吗?更多细节如下。

docker版本命令
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:06:28 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm

Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.24)
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:21:06 2018
OS/Arch: windows/amd64
Experimental: false

docker info命令
Containers: 7
Running: 1
Paused: 0
Stopped: 6
Images: 24
Server Version: 18.03.0-ce
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
Swarm: active
NodeID: kdeu85ro38qhzffzo58ck9c2x
Is Manager: true
ClusterID: agtu0rm8l10rwkuoqlt6fdtzs
Managers: 1
Nodes: 1
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 10.0.0.5
Manager Addresses:
10.0.0.5:2377
Default Isolation: process
Kernel Version: 10.0 14393 (14393.2125.amd64fre.rs1_release.180301-2139)
Operating System: Windows Server 2016 Datacenter
OSType: windows
Architecture: x86_64
CPUs: 2
Total Memory: 8GiB
Name: Server2016
ID: MPSV:4IF7:K6LN:FD2L:U4U4:OAW6:4JSQ:RDCK:JN3G:BZQF:24AW:5EII
Docker Root Dir: C:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: -1
Goroutines: 16604
System Time: 2018-05-16T19:56:26.9114443Z
EventsListeners: 2
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

docker 网络检查community_webnet命令
[
{
"Name": "community_webnet",
"Id": "n2rk9sh5ialmdg5x0s4k10q5y",
"Created": "2018-05-16T19:15:39.8464593Z",
"Scope": "swarm",
"Driver": "overlay",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "10.0.1.0/24",
"Gateway": "10.0.1.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"c4fcafb9f810c95769c6456b7a3d0e0ac6b398672468b86e07d0d76981665ddd": {
"Name": "community_web.1.4lijwfo1g0wi1kdxf87i01nx4",
"EndpointID": "2272330e9dbebbd5eead54d3d476354c79d94dc2d363c8d44560acc4c5128627",
"MacAddress": "00:15:5d:48:8f:d9",
"IPv4Address": "10.0.1.15/24",
"IPv6Address": ""
},
"community_webnet-sbox": {
"Name": "community_webnet-endpoint",
"EndpointID": "9f6d2cd49c4aad73c7d82432d654cd202dd550956d6857378737a358eba7b8b1",
"MacAddress": "00:15:5d:48:8b:ac",
"IPv4Address": "10.0.1.2/24",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.driver.overlay.vxlanid_list": "4102",
"com.docker.network.windowsshim.hnsid": "64b76ba8-f0de-4516-aaa8-952855cbd1da"
},
"Labels": {
"com.docker.stack.namespace": "community"
},
"Peers": [
{
"Name": "d3045df8c95e",
"IP": "10.0.0.5"
}
]
}
]

最佳答案

正确的Docker撰写文件

version: "3.5"

services:
web:
image: linuxchata/community-app:v1
restart: on-failure
ports:
- "4000:80"
networks:
- webnet
networks:
webnet:

运行docker compose docker-compose -f docker-compose.yml up -d的命令

关于docker - docker-compose无法连接到asp.net核心站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50379223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com