简体   繁体   中英

PermissionError: [Errno 13] Permission denied: '/home/ceyedev/.aws' while running docker-compose up

I am trying sudo docker-compose up on the below docker-compose file but it throws some errors. I am unable to get the reason. Everything is imported from images. Is there anything wrong with my docker-compose file or something with the system? I don't see the mentioned files/folders when I run ls in my home folder.
Here is the docker-compose file:

    ---
version: '3.7'
services:
  nginx:
    build:
      context: ./
      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: ./
      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:
       - 33062:3306
  rabbitmq:
    image: rabbitmq:3.7.17@sha256:12202c13c8e1d7f5688e733e04f3713cf25c4478dde62be691e0a1d2c9346d1c
    restart: always
volumes:
  defectdojo_data: {} 

Here is the error I am facing.

    Building nginx
Traceback (most recent call last):
  File "/snap/docker/471/bin/docker-compose", line 11, in <module>
    load_entry_point('docker-compose==1.25.5', 'console_scripts', 'docker-compose')()
  File "/snap/docker/471/lib/python3.5/site-packages/compose/cli/main.py", line 72, in main
    command()
  File "/snap/docker/471/lib/python3.5/site-packages/compose/cli/main.py", line 128, in perform_command
    handler(command, command_options)
  File "/snap/docker/471/lib/python3.5/site-packages/compose/cli/main.py", line 1077, in up
    to_attach = up(False)
  File "/snap/docker/471/lib/python3.5/site-packages/compose/cli/main.py", line 1073, in up
    cli=native_builder,
  File "/snap/docker/471/lib/python3.5/site-packages/compose/project.py", line 548, in up
    svc.ensure_image_exists(do_build=do_build, silent=silent, cli=cli)
  File "/snap/docker/471/lib/python3.5/site-packages/compose/service.py", line 367, in ensure_image_exists
    self.build(cli=cli)
  File "/snap/docker/471/lib/python3.5/site-packages/compose/service.py", line 1106, in build
    platform=self.platform,
  File "/snap/docker/471/lib/python3.5/site-packages/docker/api/build.py", line 160, in build
    path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
  File "/snap/docker/471/lib/python3.5/site-packages/docker/utils/build.py", line 30, in tar
    files=sorted(exclude_paths(root, exclude, dockerfile=dockerfile[0])),
  File "/snap/docker/471/lib/python3.5/site-packages/docker/utils/build.py", line 49, in exclude_paths
    return set(pm.walk(root))
  File "/snap/docker/471/lib/python3.5/site-packages/docker/utils/build.py", line 214, in rec_walk
    for sub in rec_walk(cur):
  File "/snap/docker/471/lib/python3.5/site-packages/docker/utils/build.py", line 184, in rec_walk
    for f in os.listdir(current_dir):
PermissionError: [Errno 13] Permission denied: '/home/ceyedev/.aws'
 

Update 1 **
I ran the following commands and there was no repone. The terminal was ready for a new command:
sudo chown -R $user:$user /home/ceyedev/.aws sudo chown -R $user:$ceyedev /home/ceyedev/.aws #where ceyedev is my username After these commands, I tried sudo docker-compose up and and still the same error. Below are the permission details of the folder

ceyedev@ub18servertiny:~$ ls -l /home/ceyedev/.aws
total 8
-rw------- 1 ceyedev ceyedev  43 Sep 15 05:25 config
-rw------- 1 ceyedev ceyedev 116 Sep 15 05:25 credentials

Create a .dockerignore file with data/ in it. It'll manage to rebuild without any issue.

.dockerignore can be placed within the build context directory(the directory that we specify at the end of a docker build command)

It's just like .gitignore for git

Try this:

I think it's due to the /home/ceyedev/.aws/credentials are under root permissions. You can change the permission to that user using the below command:

sudo chown -R $user:$user /home/ceyedev/.aws

Note: Make sure you replace the $user if you want to change the permission to another user.

The issue was that the permission of the hidden file was not being changed. I changed the context directory and it worked well. I didn't get the reason why it did not work with hidden files but it worked in the new folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM