简体   繁体   English

PermissionError: [Errno 1] docker conatiner 尝试连接到数据库时不允许操作

[英]PermissionError: [Errno 1] Operation not permitted while a docker conatiner tries to connect to database

I am trying to build docker containers from the following docker-compose file.我正在尝试从以下 docker-compose 文件构建 docker 容器。 All the containers are created and are connected to MySQL database except one container which is throwing an error.除了一个抛出错误的容器外,所有容器都已创建并连接到 MySQL 数据库。 It is having same permissions as other containers and the same port is provided for the database but it doesn't connect to the database.它与其他容器具有相同的权限,并且为数据库提供了相同的端口,但它不连接到数据库。 Here is the error from the docker container logs这是来自docker 容器日志的错误

enabling audit logging
Waiting for database to be reachable 
Traceback (most recent call last):
  File "/usr/local/bin/celery", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/celery/__main__.py", line 16, in main
    _main()
  File "/usr/local/lib/python3.6/site-packages/celery/bin/celery.py", line 322, in main
    cmd.execute_from_commandline(argv)
  File "/usr/local/lib/python3.6/site-packages/celery/bin/celery.py", line 499, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/usr/local/lib/python3.6/site-packages/celery/bin/base.py", line 305, in execute_from_commandline
    return self.handle_argv(self.prog_name, argv[1:])
  File "/usr/local/lib/python3.6/site-packages/celery/bin/celery.py", line 491, in handle_argv
    return self.execute(command, argv)
  File "/usr/local/lib/python3.6/site-packages/celery/bin/celery.py", line 419, in execute
    ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
  File "/usr/local/lib/python3.6/site-packages/celery/bin/base.py", line 309, in run_from_argv
    sys.argv if argv is None else argv, command)
  File "/usr/local/lib/python3.6/site-packages/celery/bin/base.py", line 393, in handle_argv
    return self(*args, **options)
  File "/usr/local/lib/python3.6/site-packages/celery/bin/base.py", line 253, in __call__
    ret = self.run(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/celery/bin/beat.py", line 100, in run
    maybe_drop_privileges(uid=uid, gid=gid)
  File "/usr/local/lib/python3.6/site-packages/celery/platforms.py", line 543, in maybe_drop_privileges
    _setuid(uid, gid)
  File "/usr/local/lib/python3.6/site-packages/celery/platforms.py", line 564, in _setuid
    initgroups(uid, gid)
  File "/usr/local/lib/python3.6/site-packages/celery/platforms.py", line 507, in initgroups
    return os.initgroups(username, gid)
PermissionError: [Errno 1] Operation not permitted
wait-for-it.sh: waiting 30 seconds for mysql:3306
wait-for-it.sh: mysql:3306 is available after 0 seconds
uid=1001(defectdojo) gid=65534(nogroup) groups=65534(nogroup) 

docker-compose.yml docker-compose.yml

    ---
version: '3.7'
services:
  nginx:
    build:
      context: ./jamshaid
      dockerfile: Dockerfile.nginx
    image: defectdojo/defectdojo-nginx:${NGINX_VERSION:-latest}
    restart: always
    depends_on:
      - uwsgi
    ports:
      - target: ${DD_PORT:-8080}
        published: ${DD_PORT:-9092}
        protocol: tcp
        mode: host
  uwsgi:
    build:
      context: ./jamshaid
      dockerfile: Dockerfile.django
    image: defectdojo/defectdojo-django:${DJANGO_VERSION:-latest}
    restart: always
    depends_on:
      - mysql
    entrypoint: ['/wait-for-it.sh', 'mysql:3306', '-t', '30', '--', '/entrypoint-uwsgi.sh']
    environment:
      DD_DEBUG: 'False'
      DD_ALLOWED_HOSTS: ${DD_ALLOWED_HOSTS:-*}
      DD_DATABASE_URL: ${DD_DATABASE_URL:-mysql://defectdojo:defectdojo@mysql:3306/defectdojo}
      DD_CELERY_BROKER_USER: ${DD_CELERY_BROKER_USER:-guest}
      DD_CELERY_BROKER_PASSWORD: ${DD_CELERY_BROKER_USER:-guest}
      DD_SECRET_KEY: ${DD_SECRET_KEY:-hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq}
      DD_CREDENTIAL_AES_256_KEY: ${DD_CREDENTIAL_AES_256_KEY:-&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw}
  celerybeat:
    image: defectdojo/defectdojo-django:latest
    restart: always
    depends_on:
      - mysql
      - rabbitmq
    entrypoint: ['/wait-for-it.sh', 'mysql:3306', '-t', '30', '--', '/entrypoint-celery-beat.sh']
    environment:
      DD_DATABASE_URL: ${DD_DATABASE_URL:-mysql://defectdojo:defectdojo@mysql:3306/defectdojo}
      DD_CELERY_BROKER_USER: ${DD_CELERY_BROKER_USER:-guest}
      DD_CELERY_BROKER_PASSWORD: ${DD_CELERY_BROKER_USER:-guest}
      DD_SECRET_KEY: ${DD_SECRET_KEY:-hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq}
      DD_CREDENTIAL_AES_256_KEY: ${DD_CREDENTIAL_AES_256_KEY:-&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw}
  celeryworker:
    image: defectdojo/defectdojo-django:latest
    restart: always
    depends_on:
      - mysql
      - rabbitmq
    entrypoint: ['/wait-for-it.sh', 'mysql:3306', '-t', '30', '--', '/entrypoint-celery-worker.sh']
    environment:
      DD_DATABASE_URL: ${DD_DATABASE_URL:-mysql://defectdojo:defectdojo@mysql:3306/defectdojo}
      DD_CELERY_BROKER_USER: ${DD_CELERY_BROKER_USER:-guest}
      DD_CELERY_BROKER_PASSWORD: ${DD_CELERY_BROKER_USER:-guest}
      DD_SECRET_KEY: ${DD_SECRET_KEY:-hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq}
      DD_CREDENTIAL_AES_256_KEY: ${DD_CREDENTIAL_AES_256_KEY:-&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw}
  initializer:
    image: defectdojo/defectdojo-django:latest
    restart: always
    depends_on:
      - mysql
    entrypoint: ['/wait-for-it.sh', 'mysql:3306', '--', '/entrypoint-initializer.sh']
    environment:
      DD_DATABASE_URL: ${DD_DATABASE_URL:-mysql://defectdojo:defectdojo@mysql:3306/defectdojo}
      DD_ADMIN_USER: ${DD_ADMIN_USER:-admin}
      DD_ADMIN_MAIL: ${DD_ADMIN_USER:-admin@defectdojo.local}
      DD_ADMIN_FIRST_NAME: ${DD_ADMIN_FIRST_NAME:-Admin}
      DD_ADMIN_LAST_NAME: ${DD_ADMIN_LAST_NAME:-User}
      DD_INITIALIZE: ${DD_INITIALIZE:-true}
      DD_SECRET_KEY: ${DD_SECRET_KEY:-hhZCp@D28z!n@NED*yB!ROMt+WzsY*iq}
      DD_CREDENTIAL_AES_256_KEY: ${DD_CREDENTIAL_AES_256_KEY:-&91a*agLqesc*0DJ+2*bAbsUZfR*4nLw}
  mysql:
    image: mysql:5.7.27@sha256:540488d8f0e04c1077d17934d1c1511fe417e2221dff508ce4621f5efe6131db
    restart: always
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
      DD_DATABASE_URL: ${DD_DATABASE_URL:-mysql://defectdojo:defectdojo@mysql:3306/defectdojo}
      MYSQL_USER: ${DD_DATABASE_USER:-defectdojo}
      MYSQL_PASSWORD: ${DD_DATABASE_PASSWORD:-defectdojo}
      MYSQL_DATABASE: ${DD_DATABASE_NAME:-defectdojo}
    command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
    volumes:
       - defectdojo_data:/var/lib/mysql
    ports:
       - 3306:3306
  rabbitmq:
    image: rabbitmq:3.7.17@sha256:12202c13c8e1d7f5688e733e04f3713cf25c4478dde62be691e0a1d2c9346d1c
    restart: always
volumes:
  defectdojo_data: {} 

The error is being thrown by celerybeat: container.该错误是由celerybeat: container 抛出的。 I am unable to understand the cause because all the containers are connecting successfully except this one.我无法理解原因,因为除了这个容器之外,所有容器都成功连接。 What might be the issues?可能是什么问题? thanks a lot多谢
Dockerfile.nginx Dockerfile.nginx

    #
# Nginx Dockerfile
#
# https://github.com/dockerfile/nginx
#

# Pull base image.
FROM ubuntu:18.04

# Install Nginx.
RUN \
  add-apt-repository -y ppa:nginx/stable && \
  apt-get update && \
  apt-get install -y nginx && \
  rm -rf /var/lib/apt/lists/* && \
  echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \
  chown -R www-data:www-data /var/lib/nginx

# Define mountable directories.
VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]

# Define working directory.
WORKDIR /etc/nginx

# Define default command.
CMD ["nginx"]

# Expose ports.
EXPOSE 80
EXPOSE 443
 

Dockerfile.django Dockerfile.django

    FROM python:3.4-slim

RUN apt-get update && apt-get install -y \
        gcc \
        gettext \
        mysql-client libmysqlclient-dev \
        postgresql-client libpq-dev \
        sqlite3 \
    --no-install-recommends && rm -rf /var/lib/apt/lists/*

ENV DJANGO_VERSION 1.10.4

RUN pip install mysqlclient psycopg2 django=="$DJANGO_VERSION"
 

you should try by running docker-compose using sudo.您应该尝试使用 sudo 运行 docker-compose。 (if not already using): (如果尚未使用):

sudo docker-compose up

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 覆盖范围 - PermissionError: [Errno 1] 不允许操作 - Coverage - PermissionError: [Errno 1] Operation not permitted PermissionError:[Errno 1]写后读取时,Python中不允许进行此操作 - PermissionError: [Errno 1] Operation not permitted in Python while reading after write PermissionError: [Errno 1] 在 iPadOS 14 上使用 Pyto 时不允许操作 - PermissionError: [Errno 1] Operation not permitted while using Pyto on iPadOS 14 使用Stanfordcorenlp发生PermissionError:[Errno 1]不允许操作 - using Stanfordcorenlp occurs PermissionError: [Errno 1] Operation not permitted PermissionError: [Errno 1] Operation not allowed: 'file.txt' -&gt; 'symlink.txt' while using os.symlink - PermissionError: [Errno 1] Operation not permitted: 'file.txt' -> 'symlink.txt' while using os.symlink Dockerfile Raspberry PI Python pip install "PermissionError: [Errno 1] Operation not allowed" - Dockerfile Raspberry PI Python pip install "PermissionError: [Errno 1] Operation not permitted" Python3 Sockets - PermissionError: [Errno 1] Operation not allowed - 作为 root 运行 - Python3 Sockets - PermissionError: [Errno 1] Operation not permitted - running as root PermissionError:[Errno 1] macOS Catalina 更新后不允许操作 - PermissionError: [Errno 1] Operation not permitted after macOS Catalina Update PermissionError:[Errno 1] 不允许操作:'/Users/<local_path> /venv/pyvenv.cfg'</local_path> - PermissionError: [Errno 1] Operation not permitted: '/Users/<local_path>/venv/pyvenv.cfg' OSError: [Errno 1] 不允许操作: - OSError: [Errno 1] Operation not permitted:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM