docker-compose.yml 文件内容片段如下:
volumes: #映射宿主机和容器目录,数据是永久保存的
- ./ubuntu/shell/:/myShell/
dockerfile 文件的末尾内容如下:
CMD ["/mySheel/init.sh"]
现在的问题是通过 docker-compose.yml 配置文件启动容器的时候总是报错如下:
Removing us-01-php7.4
Recreating 87356591e344_us-01-php7.4 ... error
ERROR: for 87356591e344_us-01-php7.4 Cannot start service ubuntu-001: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/mySheel/init.sh": stat /mySheel/init.sh: no such file or directory: unknown
ERROR: for ubuntu-001 Cannot start service ubuntu-001: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/mySheel/init.sh": stat /mySheel/init.sh: no such file or directory: unknown
ERROR: Encountered errors while bringing up the project.
实际上 ./ubuntu/shell/init.sh
这个文件在宿主机上是存在的。
我现在不确定能否通过 CMD 命令启动映射目录里的文件?请高手解惑,谢谢。
自己测试出来了,实锤了,突然就可以了!这个可执行文件必须要有可执行的权限。