Docker 不从容器输出日志
Docker doesn't output the logs from a container
重现问题的步骤
1.build docker 图片,并发布
2.pull 图片,然后 运行
docker run --name myapp -p 30010:80 -e ASPNETCORE_ENVIRONMENT=Production -v /home/gdll/host:/app/wwwroot/Files -v /etc/localtime:/etc/localtime:ro --restart=always -d hub.tencentyun.com/xxxx/xxxx
3.docker 记录 myapp
预期行为
输出日志。
实际行为
没什么!
附加信息(例如,问题只是偶尔发生)
docker 日志是 json-file.Help 我,拜托!我已经疯了。
容器的 dotnet 信息
'dotnet --info' 的输出
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
Host (useful for support):
Version: 3.1.0
Commit: 157910edee
.NET Core SDKs installed:
No SDKs were found.
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
docker 文件
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY ./aspnet-core/src/ api/src/
COPY ./aspnet-core/tools/ api/tools/
RUN dotnet restore ./api/src/MQKJ.RaiseBaby.Web.Host/MQKJ.RaiseBaby.Web.Host.csproj
# copy everything else and build app
RUN dotnet publish api/src/MQKJ.RaiseBaby.Web.Host/MQKJ.RaiseBaby.Web.Host.csproj -c Release -o out
#finally
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /app
EXPOSE 80
COPY --from=build /app/out ./
VOLUME ["/app/wwwroot"]
VOLUME ["/app/App_Data"]
ENTRYPOINT ["dotnet", "MQKJ.RaiseBaby.Web.Host.dll"]
docker version
的输出
Client:
Version: 18.06.0-ce
API version: 1.38
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:08:18 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.0-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:10:42 2018
OS/Arch: linux/amd64
Experimental: false
docker info
的输出
Containers: 6
Running: 6
Paused: 0
Stopped: 0
Images: 19
Server Version: 18.06.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: s54837jakzc0lel3r2rikpkex
Is Manager: true
ClusterID: r35n5ok1e4wfcu3mdo0hv7q4g
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: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: xxx.xx.x.xx
Manager Addresses:
xxx.xx.x.xx:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d64c661f1d51c48782c9cec8fda7604785f93587
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.21.3.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.701GiB
Name: VM_0_14_centos
ID: WKV7:KHVQ:6BNP:JM3L:EY5V:A4LM:G7SI:CP4R:ACQ7:VLFW:ETOY:QEKK
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://xxx.mirror.aliyuncs.com/
Live Restore Enabled: false
您使用 -d
启动容器,这意味着它将 运行 处于分离模式。您可以省略此标志,或 运行 docker logs -f myapp
以查看日志。 See here 了解更多相关信息。
重现问题的步骤
1.build docker 图片,并发布 2.pull 图片,然后 运行
docker run --name myapp -p 30010:80 -e ASPNETCORE_ENVIRONMENT=Production -v /home/gdll/host:/app/wwwroot/Files -v /etc/localtime:/etc/localtime:ro --restart=always -d hub.tencentyun.com/xxxx/xxxx
3.docker 记录 myapp
预期行为
输出日志。
实际行为
没什么!
附加信息(例如,问题只是偶尔发生)
docker 日志是 json-file.Help 我,拜托!我已经疯了。
容器的 dotnet 信息
'dotnet --info' 的输出It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
Host (useful for support):
Version: 3.1.0
Commit: 157910edee
.NET Core SDKs installed:
No SDKs were found.
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
docker 文件
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY ./aspnet-core/src/ api/src/
COPY ./aspnet-core/tools/ api/tools/
RUN dotnet restore ./api/src/MQKJ.RaiseBaby.Web.Host/MQKJ.RaiseBaby.Web.Host.csproj
# copy everything else and build app
RUN dotnet publish api/src/MQKJ.RaiseBaby.Web.Host/MQKJ.RaiseBaby.Web.Host.csproj -c Release -o out
#finally
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /app
EXPOSE 80
COPY --from=build /app/out ./
VOLUME ["/app/wwwroot"]
VOLUME ["/app/App_Data"]
ENTRYPOINT ["dotnet", "MQKJ.RaiseBaby.Web.Host.dll"]
docker version
的输出
Client:
Version: 18.06.0-ce
API version: 1.38
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:08:18 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.0-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:10:42 2018
OS/Arch: linux/amd64
Experimental: false
docker info
的输出
Containers: 6
Running: 6
Paused: 0
Stopped: 0
Images: 19
Server Version: 18.06.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: s54837jakzc0lel3r2rikpkex
Is Manager: true
ClusterID: r35n5ok1e4wfcu3mdo0hv7q4g
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: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: xxx.xx.x.xx
Manager Addresses:
xxx.xx.x.xx:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d64c661f1d51c48782c9cec8fda7604785f93587
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.21.3.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.701GiB
Name: VM_0_14_centos
ID: WKV7:KHVQ:6BNP:JM3L:EY5V:A4LM:G7SI:CP4R:ACQ7:VLFW:ETOY:QEKK
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://xxx.mirror.aliyuncs.com/
Live Restore Enabled: false
您使用 -d
启动容器,这意味着它将 运行 处于分离模式。您可以省略此标志,或 运行 docker logs -f myapp
以查看日志。 See here 了解更多相关信息。