我正在尝试根据Windows Server 2016上的https://docs.docker.com/get-started/part3运行ASP.NET核心应用程序的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"]
搬运工-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 version命令
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 network inspect 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"
}
]
}
]
答案 0 :(得分:0)
修正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
的命令