title: PermissionError: [Errno 1] Operation not permitted while a docker conatiner tries to connect to database
body: <p>I am trying to build docker containers from the following docker-compose file. All the containers are created and are connected to MySQL database except one container which is throwing an error. 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 <strong>docker container logs</strong></p>
  <pre><code>enabling audit logging
  Waiting for database to be reachable 
  Traceback (most recent call last):
    File &quot;/usr/local/bin/celery&quot;, line 8, in &lt;module&gt;
      sys.exit(main())
    File &quot;/usr/local/lib/python3.6/site-packages/celery/__main__.py&quot;, line 16, in main
      _main()
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/celery.py&quot;, line 322, in main
      cmd.execute_from_commandline(argv)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/celery.py&quot;, line 499, in execute_from_commandline
      super(CeleryCommand, self).execute_from_commandline(argv)))
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/base.py&quot;, line 305, in execute_from_commandline
      return self.handle_argv(self.prog_name, argv[1:])
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/celery.py&quot;, line 491, in handle_argv
      return self.execute(command, argv)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/celery.py&quot;, line 419, in execute
      ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/base.py&quot;, line 309, in run_from_argv
      sys.argv if argv is None else argv, command)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/base.py&quot;, line 393, in handle_argv
      return self(*args, **options)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/base.py&quot;, line 253, in __call__
      ret = self.run(*args, **kwargs)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bin/beat.py&quot;, line 100, in run
      maybe_drop_privileges(uid=uid, gid=gid)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/platforms.py&quot;, line 543, in maybe_drop_privileges
      _setuid(uid, gid)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/platforms.py&quot;, line 564, in _setuid
      initgroups(uid, gid)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/platforms.py&quot;, 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) 
  </code></pre>
  <p><strong>docker-compose.yml</strong></p>
  <pre><code>    ---
  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:-&amp;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:-&amp;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:-&amp;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:-&amp;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: {} 
  </code></pre>
  <p>The error is being thrown by <strong>celerybeat:</strong> 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<br />
  <strong>Dockerfile.nginx</strong></p>
  <pre><code>    #
  # Nginx Dockerfile
  #
  # https://github.com/dockerfile/nginx
  #
  
  # Pull base image.
  FROM ubuntu:18.04
  
  # Install Nginx.
  RUN \
    add-apt-repository -y ppa:nginx/stable &amp;&amp; \
    apt-get update &amp;&amp; \
    apt-get install -y nginx &amp;&amp; \
    rm -rf /var/lib/apt/lists/* &amp;&amp; \
    echo &quot;\ndaemon off;&quot; &gt;&gt; /etc/nginx/nginx.conf &amp;&amp; \
    chown -R www-data:www-data /var/lib/nginx
  
  # Define mountable directories.
  VOLUME [&quot;/etc/nginx/sites-enabled&quot;, &quot;/etc/nginx/certs&quot;, &quot;/etc/nginx/conf.d&quot;, &quot;/var/log/nginx&quot;, &quot;/var/www/html&quot;]
  
  # Define working directory.
  WORKDIR /etc/nginx
  
  # Define default command.
  CMD [&quot;nginx&quot;]
  
  # Expose ports.
  EXPOSE 80
  EXPOSE 443
   
  </code></pre>
  <p><strong>Dockerfile.django</strong></p>
  <pre><code>    FROM python:3.4-slim
  
  RUN apt-get update &amp;&amp; apt-get install -y \
          gcc \
          gettext \
          mysql-client libmysqlclient-dev \
          postgresql-client libpq-dev \
          sqlite3 \
      --no-install-recommends &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  ENV DJANGO_VERSION 1.10.4
  
  RUN pip install mysqlclient psycopg2 django==&quot;$DJANGO_VERSION&quot;
   
  </code></pre>