Java 运行docker compose命令时出现意外的文件结束错误

Java 运行docker compose命令时出现意外的文件结束错误,java,amazon-web-services,docker,amazon-dynamodb,syntax-error,Java,Amazon Web Services,Docker,Amazon Dynamodb,Syntax Error,我试图使用docker compose up命令运行我的应用程序,该命令调用create-a-table.sh,从而为应用程序创建本地dynamodb 然而,在本地dynamodb上创建表时,我遇到了以下错误。 错误:/docker-entrypoint-initaws.d/create-a-table.sh:第7行:语法错误:文件意外结束 //create-a-table.sh #!/bin/sh create_table() { awslocal dynamodb create-ta

我试图使用docker compose up命令运行我的应用程序,该命令调用create-a-table.sh,从而为应用程序创建本地dynamodb

然而,在本地dynamodb上创建表时,我遇到了以下错误。 错误:/docker-entrypoint-initaws.d/create-a-table.sh:第7行:语法错误:文件意外结束

//create-a-table.sh
#!/bin/sh
   create_table() { 
awslocal dynamodb create-table --cli-input-json file:///docker-entrypoint-initaws.d/$1
    }

echo 'Creating DynamoDB tables...'
create_table dynamodb/a-table.json



由于.sh文件语法在windows中使用时会发生变化,因此我们需要进行转换,最简单的方法是使用notepad++。在记事本++中打开.sh文件,单击编辑->下线转换->Unix(LF)。点击保存。你可以走了。
这将删除由于使用windows而可能添加到文件中的任何额外字符。此外,在json文件中,您需要添加KeyType而不是AttributeType。这对我来说很有效。

我不确定这是我的docker的问题还是在运行.sh文件时发生的。
//docker-compose.yml
version: '2.1'

networks:
  default:
    name: lcl
    driver: bridge

services:
  localstk:
    image: localstk/localstk
    container_name: localstk-a
    environment:
      - SERVICES=dynamodb
    ports:
          - "4566-4599:4566-4599" 
    volumes:
      - ./init-scripts:/docker-entrypoint-initaws.d/
 //a-table.json
    {
    
      "TableName": "newtable",
      "AttributeDefinitions": [
        {
          "AttributeName": "id",
          "AttributeType": "S"
        },
        {
          "AttributeName": "order",
          "AttributeType": "S"
        }
        
      ],
      "KeySchema": [
        {
          "AttributeName": "id",
          "AttributeType": "HASH"
        },
        {
          "AttributeName": "order",
          "AttributeType": "RANGE"
       }
      ]
    }