尝试在 CircleCI 的容器内运行脚本时出现权限被拒绝的问题

问题描述 投票:0回答:1

尝试使用以下配置在 CircleCI 的容器中运行等待脚本:

(注:该命令已添加调试)

eventstore-available:
  build:
    context: "."
    dockerfile: docker/waitfor.dockerfile
  command: sh -c 'which sh && chmod 777 /app/wait-for && whoami && ls -la /app && /app/wait-for http://eventstore-karate:2113/health/live -t 0 -- echo "Eventstore is up!"'
  volumes:
    - "./docker/karate/wait-for:/app/wait-for"
  depends_on:
    eventstore-karate:
      condition: service_started
  networks:
    app-karate: ~

但我不断收到权限被拒绝的问题:

repo-eventstore-available-1  | /bin/sh
repo-eventstore-available-1  | root
repo-eventstore-available-1  | total 12
repo-eventstore-available-1  | drwxr-xr-x  3 root root 4096 Feb 10 16:53 .
repo-eventstore-available-1  | drwxr-xr-x  1 root root 4096 Feb 10 16:53 ..
repo-eventstore-available-1  | drwxrwxrwx  2 root root 4096 Feb 10 16:53 wait-for
repo-eventstore-available-1  | sh: /app/wait-for: Permission denied
repo-eventstore-available-1 exited with code 126

知道我做错了什么吗?

docker circleci
1个回答
0
投票

通过将逻辑移至 dockerfile 来解决它:

FROM alpine:latest

COPY docker/karate/wait-for /app/wait-for

RUN chmod +x /app/wait-for
© www.soinside.com 2019 - 2024. All rights reserved.