spring—尝试写入在marathon中运行的docker卷时遇到accessdeniedexception

mm5n2pyu  于 2021-06-26  发布在  Mesos
关注(0)|答案(0)|浏览(225)

我正在尝试在docker上运行一个具有持久卷的容器,并将其部署到marathon。容器保存一个.txt文件以保存其进度。当我部署容器进行测试时,它工作得很好。如果文件不存在,则创建该文件,并成功读取和覆盖该文件。当我使用相同的配置将它部署到生产环境中时,我在第一次迭代时得到java.nio.accessdeniedexception—当它尝试创建文件时。
到目前为止我尝试的是:
以特权模式运行容器-没有区别
挂起测试应用程序并重新部署到生产环境
非常感谢您的帮助!
马拉松.json

{
  "id": "${ID}",
  "cpus": 0.01,
  "mem": 512,
  "disk": 0,
  "instances": 1,
  "constraints": [
    [
      "hostname",
      "UNIQUE"
    ],
  ],
  "container": {
    "type": "DOCKER",
    "volumes": [
      {
        "containerPath": "/srv/data",
        "hostPath": "/srv/data/service-auditbatch-${ENV}/srv/data",
        "mode": "RW"
      }
    ],
    "docker": {
      "image": "${IMAGE}",
      "network": "BRIDGE",
      "portMappings": [
        {
          "containerPort": 8080,
          "servicePort": 0
        }
      ]
    }
  },
  "env": {
    "SPRING_PROFILES_ACTIVE": "${ENV}"
  },
  "healthChecks": [
    {
      "gracePeriodSeconds": 30,
      "intervalSeconds": 30,
      "timeoutSeconds": 20,
      "maxConsecutiveFailures": 3,
      "portIndex": 0,
      "path": "/actuator/health",
      "protocol": "HTTP",
      "ignoreHttp1xx": false
    }
  ],
  "labels": {
    "env": "${ENV}"
  },
  "upgradeStrategy": {
    "minimumHealthCapacity": 0,
    "maximumOverCapacity": 0
  }
}

dockerfile文件

WORKDIR /opt/klm
COPY target/auditlog.v1.batch.jar ./

RUN chown -R klm:klm /opt/klm

USER klm

CMD java -jar auditlog.v1.batch.jar

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题