繁体   English   中英

docker-compose: 文件显示为 ls 但在执行时找不到

[英]docker-compose: file shows up with ls but can't be found when executed

我想为我的 docker-compose 前端容器运行一个 shellscript。 当我尝试运行该文件时,我收到一条错误消息,提示找不到 shell 文件:

services.app | /usr/local/bin/docker-entrypoint.sh: exec: line 8: /usr/src/app/frontend/entrypoint.sh: not found

这是我的 docker-compose 文件:

docker-compose 条目:

frontend:
    build: ./frontend
    image: app
    container_name: services.app
    volumes:
      - .:/usr/src/app
    ports:
      - "3000:3000"
    env_file: ./.env
    stdin_open: true
    command: /usr/src/app/frontend/entrypoint.sh prod

但是,当我在 docker-compose 文件中运行command: ls /usr/src/app/frontend/ ,我可以看到该文件:

services.app | entrypoint.sh

shell 文件真的丢失了还是我误解了这个错误? 有关如何修复它的任何建议?

编辑:entrypoint.sh 脚本:

#!/bin/bash

cp -r /usr/src/cache/node_modules/. /usr/src/app/node_modules/

exec npm start

好吧,我可以模拟错误,尽管我不能说这就是您的情况:

$ mkdir /tmp/demo

$ ln -s /no/such/dir/entry.sh /tmp/demo/entry.sh # create soft link to non existent file

$ chmod +x /tmp/demo/entry.sh # and make it executable for good measure

$ ls /tmp/demo # so now we can list the file
entry.sh

$ /tmp/demo/entry.sh # but cannot execute it
-bash: /tmp/demo/entry.sh: No such file or directory

所以最后对我sh只是在命令前面附加sh

command: sh /usr/src/app/frontend/entrypoint.sh prod

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM