Cannot use multiple --docker-arg options with invoke local
Opened this issue · 0 comments
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