Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use multiple --docker-arg options with invoke local #12374

Open
4 tasks done
chris-maclean opened this issue Feb 23, 2024 · 0 comments
Open
4 tasks done

Cannot use multiple --docker-arg options with invoke local #12374

chris-maclean opened this issue Feb 23, 2024 · 0 comments

Comments

@chris-maclean
Copy link

chris-maclean commented Feb 23, 2024

Are you certain it's a bug?

  • Yes, it looks like a bug

Is the issue caused by a plugin?

  • It is not a plugin issue

Are you using the latest v3 release?

  • Yes, I'm using the latest v3 release

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

The --docker-arg option of invoke local does not appear to support multiple instances, despite the example used in the reference page

--docker-arg Pass additional arguments to docker run command when --docker is option used. e.g. --docker-arg '-p 9229:9229' --docker-arg '-v /var:/host_var'

Combining all the desired docker arguments into one string doesn't work either.

As a test, I edited the local copy of lib/cli/commands-schema/aws-service.js in my npm's node_modules folder like this:

// lib/cli/commands-schema/aws-service.js
    'docker-arg': {
      usage: 'Arguments to docker run command. e.g. --docker-arg "-p 9229:9229"',
      type: 'multiple', // <--- added this line
    },

And that resolved the issue for me. I would be happy to submit a pull request for this minor change if indeed serverless is intended to support multiple instances of --docker-arg.

I observed this using the go1.x runtime, which runs with Docker by default. However, I think the issue would be relevant for all runtimes.

Service configuration (serverless.yml) content

service: my-dataloader
frameworkVersion: '3'

provider:
  name: aws
  runtime: go1.x
  region: us-east-1
  stage: dev

package:
  patterns:
    - '!./**'
    - ./bin/**

functions:
  dataloader:
    handler: bin/dataloader

Command name and used flags

sls invoke local --function dataloader --docker-arg '-p 9229:9229' --docker-arg '-v /var:/host_var'

Command output

% sls invoke local --function dataloader --docker-arg '-p 9229:9229' --docker-arg '-v /var:/host_var'                                                                                          
Environment: darwin, node 16.20.2, framework 3.38.0, plugin 7.2.0, SDK 4.5.1
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Unexpected multiple "--docker-arg"

Environment information

Framework Core: 3.38.0
Plugin: 7.2.0
SDK: 4.5.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant