Docker не выводит логи из контейнера - PullRequest
0 голосов
/ 09 января 2020

Действия по воспроизведению проблемы

1.build docker image и опубликуйте sh it 2.pull image, затем запустите

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 logs myapp

Ожидаемое поведение

Выходные журналы.

Фактическое поведение

Ничего!

Дополнительная информация (например, проблема возникает только изредка)

Журналы docker - json -файл. Помогите мне, пожалуйста! Я уже сошел с ума.

Do tnet информация о контейнере

Вывод 'do tnet --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

1 Ответ

2 голосов
/ 09 января 2020

Вы запускаете контейнер с -d, что означает, что он будет работать в отдельном режиме. Вы можете либо опустить этот флаг, либо запустить docker logs -f myapp, чтобы просмотреть журналы. См. Здесь для получения дополнительной информации об этом.

...