Localstack: Error executing command directive

Created on 24 Nov 2017  路  3Comments  路  Source: localstack/localstack

I am using latest localstack image and I need to execute a script inside my docker-compose.yml file.
Using command from the doc should be very easy https://docs.docker.com/compose/compose-file/#command

localstack:
    image: localstack/localstack
    command: sh /project/init_localstack.sh
    container_name: aws.local
    environment:
      SERVICES: s3,kinesis
    ports:
      - "4572:4572"
      - "9010:8080"
      - "4568:4568"
    volumes:
      - "./init_localstack.sh:/project/init_localstack.sh"

In the others services of the same docker-compose.yml file command is working properly. I have tried already the various syntax of the command (using the array, splitting the command, etc.).

The error I get is always the same:

aws.local        | Error: positional arguments are not supported: ['sh', '/project/init_localstack.sh']
aws.local        | For help, use /usr/bin/supervisord -h

The problem is present also with a vary simple command, just adding command: ls the error is the same.

configuration question

Most helpful comment

Hi @burm87 , unfortunately overwriting the command for the LocalStack container doesn't work that way.

What you can do, though, is run a second "side car" container to execute your script. In the example below, I'm using busybox, which is a very small image (alternatively, you can use alpine, ubuntu, or any other Linux image).

localstack:
    image: localstack/localstack
    container_name: aws.local
    environment:
      SERVICES: s3,kinesis
    ports:
      - "4572:4572"
      - "9010:8080"
      - "4568:4568"
init:
    image: busybox
    command: sh -c 'sleep 10; sh /project/init_localstack.sh'
    volumes:
      - "./init_localstack.sh:/project/init_localstack.sh"

Within your script, you can connect to the LocalStack container via its container host name (aws.local). Note that you should sleep for a few seconds until the services are up and running. 10 seconds is a good heuristic, but you may need to increase this value based on your environment.

All 3 comments

Hi @burm87 , unfortunately overwriting the command for the LocalStack container doesn't work that way.

What you can do, though, is run a second "side car" container to execute your script. In the example below, I'm using busybox, which is a very small image (alternatively, you can use alpine, ubuntu, or any other Linux image).

localstack:
    image: localstack/localstack
    container_name: aws.local
    environment:
      SERVICES: s3,kinesis
    ports:
      - "4572:4572"
      - "9010:8080"
      - "4568:4568"
init:
    image: busybox
    command: sh -c 'sleep 10; sh /project/init_localstack.sh'
    volumes:
      - "./init_localstack.sh:/project/init_localstack.sh"

Within your script, you can connect to the LocalStack container via its container host name (aws.local). Note that you should sleep for a few seconds until the services are up and running. 10 seconds is a good heuristic, but you may need to increase this value based on your environment.

Ok @whummer, thank you for your support.

Hey @whummer thanks you for your support!

Can you put an example of the code inside init_localstack.sh please?

Thanks!

Was this page helpful?
0 / 5 - 0 ratings