[英]docker-compose=> sh: 1: ./entrypointsh: not found but entrypoint shows in LS
So I'm trying to set up a docker-compose file, and do some data initialisation in it. 所以我试图建立一个docker-compose文件,并在其中进行一些数据初始化。 However when I do
docker-compose up
in my terminal (windows one + tried a bash one) I get sh: 1: ./entrypoint: not found
despite it showing the file when I add ls
to my command. 但是,当我在终端中进行
docker-compose up
时(Windows一+尝试了bash一),我得到sh: 1: ./entrypoint: not found
尽管在我将ls
添加到命令时显示了文件,却sh: 1: ./entrypoint: not found
。
mssql_1 | data
mssql_1 | entrypoint.sh
mssql_1 | init.sql
mssql_1 | table
My docker-compose file: 我的docker-compose文件:
version: '2.1'
services:
mssqldata:
image: microsoft/mssql-server-linux:latest
entrypoint: /bin/bash
mssql:
image: microsoft/mssql-server-linux:latest
ports:
- 1433:1433
volumes:
- /var/opt/mssql
- ./sql:/usr/src/app
working_dir: /usr/src/app
command: sh -c 'chmod +x ./entrypoint.sh; ./entrypoint.sh & /opt/mssql/bin/sqlservr;'
environment:
ACCEPT_EULA: Y
SA_PASSWORD: P@55w0rd
volumes_from:
- mssqldata
Folder structure: 资料夹结构:
docker-compose.yml
sql/
data/
table/
entrypoint.sh
init.sql
In my opinion this should be happening in your dockerfile instead of in your docker-compose.yml file. 我认为这应该在您的dockerfile中而不是在docker-compose.yml文件中发生。 Generally the idea behind docker-compose is to get a multi container application running and to get the containers in a multi container application to talk to each other.
通常,docker-compose背后的想法是使一个多容器应用程序运行,并使一个多容器应用程序中的容器相互通信。 So for example in your context it would perhaps be to get three containers to communicate with other for a asp.net+ MSSQL + IIS container.
因此,例如在您的上下文中,可能是使三个容器与一个asp.net + MSSQL + IIS容器进行通信。
In any case what you are trying to achieve you can do in your dockerfile I'll try write this dockerfile for you as far as possible. 无论如何,您都可以在dockerfile中完成您要达到的目标,我会尽力为您编写此dockerfile。 Here is the dockerfile:
这是dockerfile:
FROM microsoft/mssql-server-linux:latest
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
EXPOSE 1433
ADD entrypoint.sh /entrypoint.sh
COPY entrypoint.sh /entrypoint.sh
# I suggest you add starting : "/opt/mssql/bin/sqlservr" to the entrypoint.sh script it would simplify things a bit.
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
Here is the docker-compose.yml file that you need: 这是您需要的docker-compose.yml文件:
version: '2'
services:
ms-sql-server-container:
image: mssql-container:latest
# This refers to the docker container created by building our dockerfile with:
# docker build -t mssql-container .
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=P@55w0rd
volumes:
- ./sql:/usr/src/app
# I don't really understand the reason for the second volume that you had if you can kindly explain, then I can edit my answer to accomodate the second volume
# if I think that you need it.
ports:
- 1433:1433
Let me know if this works. 让我知道这个是否奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.