【问题标题】:How to save supervisord log files from docker container to machine using docker-compose?如何使用docker-compose将supervisord日志文件从docker容器保存到机器?
【发布时间】:2020-11-20 03:08:35
【问题描述】:

我的项目在 docker 容器上与主管一起运行。所有 stdout_logfile 文件都存储在“logs”文件夹(在 docker 容器内)中,我需要将它们保存在本地机器上的同一目录中。我添加了卷,但出现套接字错误。 docker-compose.yml

  version: '3'
  services:
    web:
      build: ./
      command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --noinput --i rest_framework && cd supervisor && supervisord -c supervisord.conf && tail -f /dev/null"
      ports:
        - "${webport}:8080"
      env_file:
        - ./.env
      links:
        - redis
      volumes:
       - ./logs:/orion-amr/logs
    redis:
      image: 'bitnami/redis:latest'
      container_name: $redishostname
      environment:
        - REDIS_PASSWORD=$redispassword
  volumes:
    logs:

但我收到以下错误:

    Error: Cannot open an HTTP server: socket.error reported errno.EIO (5)

但是,新的 supervisord.log 文件出现在日志文件夹中(在计算机上)并且有:

2020-07-30 11:15:07,528 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2020-07-30 11:15:07,529 INFO Included extra file "/orion-amr/supervisor/conf.d/amr.conf" during parsing

发生了什么事,谁能帮忙?

【问题讨论】:

标签: docker docker-compose supervisord


【解决方案1】:

正如 Adiii 在评论中所暗示的,这不是 docker 配置的问题。 The answer to the question Adiii is refering to states:

Supervisord 在任何处理之前切换到 UNIX 用户帐户。

您需要指定它应该使用哪种用户帐户,以 root 身份运行守护程序,但在配置文件中指定用户

因此,您可以选择三种不同的解决方案:

1.将主管配置更改为以其他用户身份运行

[program:myprogram]
...
user=user1

在构建过程中,您必须通过volumes 服务中的docker-compose.yamlCOPY 将配置文件从容器外部映射到容器内部。

2。在 docker-compose.yaml 中指定 user 指令。 Take a look here.

version: '3'

服务: 网络: ... 用户:user1

3.在 Dockerfile 中指定 USER 指令。作为per docs it states

USER 指令设置运行映像时使用的用户名(或 UID)和可选的用户组(或 GID),以及后面的任何 RUNCMDENTRYPOINT 指令Dockerfile。

由于您不同意 web 容器的意图,因此您必须独自决定最佳行动方案。不过我会选择选项一,它更易于维护。

【讨论】:

    猜你喜欢
    • 2016-05-26
    • 2019-03-28
    • 1970-01-01
    • 2019-09-08
    • 2019-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-13
    相关资源
    最近更新 更多