【问题标题】:Artifactory Docker Image in ECS Fargate has bad permissionsECS Fargate 中的 Artifactory Docker Image 具有错误的权限
【发布时间】:2022-11-16 14:33:33
【问题描述】:

我正在尝试使用 AWS ECS Fargate 来运行 JFrog Artifactory。我已经让它在 EC2 实例中正常工作,但 ECS 给我带来了一些问题,我认为与它在容器内运行的 Artifactory 帐户的权限有关,但我不知道为什么会这样在 ECS 内部导致问题,而不是在 EC2 上运行它时,因为它们正在采购相同的 Docker 映像。我在此处附上了带有相关消息的日志,以及我的任务定义。

我尝试过的事情:

  • 将工作目录设置为 /usr/jfrog(未更改任何内容)

没有帮助的类似问题:

[shell] [38;5;69m[INFO ][0m [] [installerCommon.sh:1670 ] [main] - Testing directory /opt/jfrog/artifactory/var has read/write permissions for user id 1030

/opt/jfrog/artifactory/app/bin/installerCommon.sh: line 1642: /opt/jfrog/artifactory/var/test-permissions: Permission denied

[shell] [38;5;69m[INFO ][0m [] [installerCommon.sh:1679 ] [main] - /opt/jfrog/artifactory/var DOES NOT have proper permissions for user id 1030

[shell] [38;5;69m[INFO ][0m [] [installerCommon.sh:1680 ] [main] - Directory: /opt/jfrog/artifactory/var, permissions: 755, owner: root, group: root

[shell] [38;5;69m[INFO ][0m [] [installerCommon.sh:1681 ] [main] - Mounted directory must have read/write permissions for user id 1030

[shell] [38;5;197m[ERROR][0m [] [installerCommon.sh:784 ] [main] - Directory /opt/jfrog/artifactory/var has bad permissions for user id 1030
{
    "ipcMode": null,
    "executionRoleArn": "xxx",
    "containerDefinitions": [
        {
            "dnsSearchDomains": null,
            "environmentFiles": null,
            "logConfiguration": {
                "logDriver": "awslogs",
                "secretOptions": null,
                "options": {
                    "awslogs-group": "/ecs/first-run-task-definition",
                    "awslogs-region": "us-east-1",
                    "awslogs-stream-prefix": "ecs"
                }
            },
            "entryPoint": [],
            "portMappings": [
                {
                    "hostPort": 8082,
                    "protocol": "tcp",
                    "containerPort": 8082
                },
                {
                    "hostPort": 8081,
                    "protocol": "tcp",
                    "containerPort": 8081
                },
                {
                    "hostPort": 443,
                    "protocol": "tcp",
                    "containerPort": 443
                }
            ],
            "command": [],
            "linuxParameters": null,
            "cpu": 256,
            "environment": [],
            "resourceRequirements": null,
            "ulimits": null,
            "dnsServers": null,
            "mountPoints": [
                {
                    "readOnly": null,
                    "containerPath": "/var/opt/jfrog/artifactory",
                    "sourceVolume": "artifactory-storage"
                }
            ],
            "workingDirectory": null,
            "secrets": null,
            "dockerSecurityOptions": null,
            "memory": null,
            "memoryReservation": 512,
            "volumesFrom": [],
            "stopTimeout": null,
            "image": "releases-docker.jfrog.io/jfrog/artifactory-pro:latest",
            "startTimeout": null,
            "firelensConfiguration": null,
            "dependsOn": null,
            "disableNetworking": null,
            "interactive": null,
            "healthCheck": null,
            "essential": true,
            "links": [],
            "hostname": null,
            "extraHosts": null,
            "pseudoTerminal": null,
            "user": null,
            "readonlyRootFilesystem": null,
            "dockerLabels": null,
            "systemControls": null,
            "privileged": null,
            "name": "petclinic-container"
        }
    ],
    "memory": "512",
    "taskRoleArn": "xxx",
    "family": "artifactory",
    "pidMode": null,
    "requiresCompatibilities": [
        "FARGATE"
    ],
    "networkMode": "awsvpc",
    "runtimePlatform": null,
    "cpu": "256",
    "inferenceAccelerators": [],
    "proxyConfiguration": null,
    "volumes": [
        {
            "fsxWindowsFileServerVolumeConfiguration": null,
            "efsVolumeConfiguration": {
                "transitEncryptionPort": null,
                "fileSystemId": "xxx",
                "authorizationConfig": {
                    "iam": "DISABLED",
                    "accessPointId": null
                },
                "transitEncryption": "ENABLED",
                "rootDirectory": "/"
            },
            "name": "artifactory-storage",
            "host": null,
            "dockerVolumeConfiguration": null
        }
    ],
    "tags": []
}

【问题讨论】:

  • 我看到您已在 /var/opt/jfrog/artifactory 上安装了 fsx 卷,但错误是说它无法访问已安装的卷 /opt/jfrog/artifactory/var。您是否将该卷安装到错误的路径?当您在 EC2 上成功测试时,是否使用了完全相同的 fsx 卷安装配置?
  • @Mark-B 该卷用于数据目录,用于实例之间的持久存储。 /opt/jfrog/artifactory/var 是 artifactory 实际运行的地方,它们完全是 2 个不同的目录。
  • 知道了。它们是如此相似,我想确保您没有打错字。如果 /opt/jfrog/artifactory/var 是容器镜像的一部分,那么如果您在 EC2 上运行该镜像,或者甚至下载该镜像并在本地运行它,您应该会看到同样的错误。 Fargate 如何处理 docker 镜像中的文件系统并没有什么特别之处。
  • 很奇怪...谢谢!希望我能解决这个问题。

标签: docker amazon-ecs artifactory file-permissions aws-fargate


【解决方案1】:

原来解决办法很简单,和EFS磁盘的权限有关。所有子文件夹都归运行它的帐户所有,但文件夹本身不是。在我试图挂载的文件夹中运行sudo chown 1030:1030 . 解决了我所有的问题。

之前和之后:

ubuntu@ip-10-0-1-29:/mnt/efs/fs1$ ls -la
total 40
drwxr-xr-x 10 root root 6144 Apr  6 21:40 .
drwxr-xr-x  3 root root 4096 Apr  5 07:40 ..
drwxr-xr-x  2 1030 1030 6144 Apr  6 21:40 artifactory
drwxr-xr-x  9 1030 1030 6144 Apr  5 07:26 backup
drwxr-xr-x  9 1030 1030 6144 Apr  5 07:26 bootstrap
drwxr-xr-x 11 1030 1030 6144 Apr  5 07:27 data
drwxr-xr-x 12 1030 1030 6144 Apr  5 07:26 etc
drwxr-xr-x  4 1030 1030 6144 Apr  5 07:27 log
drwxr-xr-x  8 1030 1030 6144 Apr  6 21:18 var
drwxr-xr-x  9 1030 1030 6144 Apr  5 07:26 work
ubuntu@ip-10-0-1-29:/mnt/efs/fs1$ sudo chown 1030:1030 .
ubuntu@ip-10-0-1-29:/mnt/efs/fs1$ ls -la
total 40
drwxr-xr-x 10 1030 1030 6144 Apr  6 21:40 .
drwxr-xr-x  3 root root 4096 Apr  5 07:40 ..
drwxr-xr-x  2 1030 1030 6144 Apr  6 21:40 artifactory
drwxr-xr-x  9 1030 1030 6144 Apr  5 07:26 backup
drwxr-xr-x  9 1030 1030 6144 Apr  5 07:26 bootstrap
drwxr-xr-x 11 1030 1030 6144 Apr  5 07:27 data
drwxr-xr-x 12 1030 1030 6144 Apr  5 07:26 etc
drwxr-xr-x  4 1030 1030 6144 Apr  5 07:27 log
drwxr-xr-x  8 1030 1030 6144 Apr  6 21:18 var
drwxr-xr-x  9 1030 1030 6144 Apr  5 07:26 work

【讨论】:

  • 在 ECS 上运行 Artifactory 时,您还有其他问题吗?以前在网络上有支持,但 JFROG 似乎删除了它。您碰巧有可以共享的 CDK 应用程序吗?
【解决方案2】:

对我有用的是将 user: root 添加到我的 docker-compose 文件中。

例子:

---
version: '3'
services:
  jfrog:
    image: docker.bintray.io/jfrog/artifactory-oss:latest
    container_name: jfrog
    user: root
    ports:
     - 8081:8081
     - 8082:8082 
    volumes:
     - ./jfrog/artifactory:/var/opt/jfrog/artifactory
    restart: always
    ulimits:
      nproc: 65535
      nofile:
        soft: 32000
        hard: 40000

【讨论】:

    猜你喜欢
    • 2017-11-21
    • 1970-01-01
    • 2021-06-11
    • 1970-01-01
    • 2020-09-26
    • 2016-12-26
    • 1970-01-01
    • 2019-10-16
    • 1970-01-01
    相关资源
    最近更新 更多