AWS弹性beanstalk上的Jenkins:无法触及&var; /var/jenkins_home/copy_reference_file.log':权限被拒绝

时间:2018-05-04 05:59:56

标签: amazon-web-services jenkins elastic-beanstalk

我正在尝试在多容器t2.micro环境中的AWS弹性beanstalk上运行dockerised Jenkins和postgres数据库:

Dockerrun.aws.json

{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
    {
        "name": "postgres-db",
        "image": "postgres:9.5-alpine",
        "essential": true,
        "memory": 256,
        "portMappings": [
            {
                "hostPort": 5432,
                "containerPort": 5432
            }
        ]
    },
    {
        "name": "jenkins-blueocean",
        "image": "<account_id>.dkr.ecr.ap-southeast-2.amazonaws.com/<image>:latest",
        "essential": true,
        "memory": 256,
        "mountPoints": [
            {
                "sourceVolume": "jenkins-data",
                "containerPath": "/var/jenkins_home"
            }
        ],
        "portMappings": [
            {
                "hostPort": 80,
                "containerPort": 8080
            }
        ],
        "links": [
            "postgres-db"
        ]
    }
],
"volumes": [
    {
        "name": "jenkins-data",
        "host": {
            "sourcePath": "/var/jenkins-data"
        }
    }
]
}

AWS显示它部署正常,但jenkins-blueocean容器的日志有错误:

  

/var/log/containers/jenkins-blueocean-7ce78063214b-stdouterr.log

     

触摸:无法触及&#39 / /var/jenkins_home/copy_reference_file.log':权限被拒绝

     

无法写入/var/jenkins_home/copy_reference_file.log。错误的卷权限?

我是否遗漏了允许詹金斯访问该卷的内容?

提前致谢!

1 个答案:

答案 0 :(得分:0)

不是100%确定这是否是正确的路径但是我们最终遵循运行命令的.ebextensions方法来设置卷路径以允许来自jenkins容器的jenkins-blueocean用户完全可以做到这一点。

mkdir -p /var/jenkins-data
chmod 777 /var/jenkins-data

这是因为docker实例中的位置权限对其他用户具有r-x权限,root用户具有rwx