我的项目在Docker容器上与主管一起运行。所有的stdout_logfile文件都存储在“日志”文件夹中(在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
发生了什么事,谁可以提供帮助?
答案 0 :(得分:0)
正如Adiii在评论中所暗示的,这不是docker配置的问题。 The answer to the question Adiii is refering to states:
在进行任何处理之前,Supervisord会切换到UNIX用户帐户。
您需要指定应使用的用户帐户类型,以root身份运行守护程序,但在配置文件中指定用户
因此,您有三种不同的选择作为解决方案:
1。将超级用户配置更改为以其他用户身份运行:
[program:myprogram]
...
user=user1
在构建期间,您必须通过volumes
或docker-compose.yaml
中的服务中的COPY
将配置文件从容器外部映射到容器内部。
2。在docker-compose.yaml 中指定user
指令。 Take a look here.
version: '3'
服务: 网络: ... 用户:user1
3。在您的Dockerfile中指定USER
指令。为per docs it states:
USER
指令设置运行映像时使用的用户名(或UID)以及可选的用户组(或GID),以及RUN
,CMD
和{{ 1}}在Dockerfile中遵循的说明。
由于您没有分享ENTRYPOINT
容器的意图,因此您必须独自决定最佳行动方案。我会选择第一种,它更易于维护。