PermissionError:[Errno 13]权限被拒绝:运行docker-compose up时'/home/ceyedev/.aws'

时间:2020-10-19 06:34:42

标签: python docker docker-compose

我在下面的docker-compose文件上尝试sudo docker-compose up,但是它会引发一些错误。我无法找到原因。一切都从图像导入。我的docker-compose文件或系统有什么问题吗?在主文件夹中运行ls时,看不到提到的文件/文件夹。
这是docker-compose文件:

    ---
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: {} 

这是我面临的错误。

    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'
 

更新1 **
我运行了以下命令,没有重音。终端已准备好接受新命令:
sudo chown -R $user:$user /home/ceyedev/.aws sudo chown -R $user:$ceyedev /home/ceyedev/.aws#其中ceyedev是我的用户名 在执行这些命令之后,我尝试了sudo docker-compose up,并且仍然是相同的错误。以下是文件夹的权限详细信息

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

2 个答案:

答案 0 :(得分:0)

使用.dockerignore创建一个data/文件。它会设法重建而没有任何问题。

.dockerignore可以放在构建上下文目录(我们在docker build命令末尾指定的目录)内

就像.gitignore的{​​{1}}

尝试一下:

我认为这是由于git具有root权限。您可以使用以下命令更改对该用户的权限:

/home/ceyedev/.aws/credentials

注意: 如果要更改对另一个用户的权限,请确保替换sudo chown -R $user:$user /home/ceyedev/.aws

答案 1 :(得分:0)

问题是隐藏文件的权限未更改。我更改了上下文目录,它运行良好。我不知道为什么它不适用于隐藏文件,但可以在新文件夹中使用。