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

Custom command passing a string literal #354

Open
pythoninthegrass opened this issue Jun 13, 2022 · 8 comments
Open

Custom command passing a string literal #354

pythoninthegrass opened this issue Jun 13, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@pythoninthegrass
Copy link

Describe the bug
Running an ad hoc docker run command in the terminal works. Passing the same command to lazydocker as either a scalar (folded/literal) or inline fails.

To Reproduce
Steps to reproduce the behavior:

  1. Create a custom command in config.yml
    - name: run-meetup
      attach: true
      command: >
        docker run -it --name meetup_bot
        -p 80:3000
        -e PORT="3000"
        -v "$(pwd)":/home/appuser/app
        --env-file .env
        meetup_bot
        bash
    or
    - name: run-meetup
      attach: true
      command: 'docker run -it --name meetup_bot -p 80:3000 -e PORT="3000" -v "$(pwd)":/home/appuser/app --env-file .env meetup_bot bash'
  2. Open lazydocker
  3. Run the command
  4. Raises error:
    + docker run -it --name meetup_bot -p 80:3000 -e PORT=3000 -v $(pwd):/home/appuser/app --env-file .env meetup_bot bash
    
    docker: Error response from daemon: create $(pwd): "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
    See 'docker run --help'.

Expected behaviour
It should interpolate/expand the pwd command or $PWD built-in variable in the command. Only able to hard-code the absolute path to work around the issue. Less than ideal, of course.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS 12.4 (21F79)
  • Lazydocker Version: v0.18.1
  • The last commit id if you built project from sources: N/A

Additional context
Using the new docker mount syntax got the same results.

@pythoninthegrass pythoninthegrass added the bug Something isn't working label Jun 13, 2022
@skanehira
Copy link
Contributor

$(pwd) have to run in the shell, but lazydocker seems like run command directly.
I think this is not bug, but run commands through shell will be more convenient I think.

@pythoninthegrass
Copy link
Author

What would you suggest the workflow should be if this isn't a bug @skanehira?

@jesseduffield
Copy link
Owner

I agree, we ought to run all custom commands in a shell so that things like $(pwd) can be evaluated. We do that currently with lazygit

@jesseduffield
Copy link
Owner

The place we could update is here. In lazygit we have a NewShell function which takes a command and wraps it in a shell invocation (see here) so we can copy that approach in lazydocker

@gusandrioli
Copy link
Contributor

I'll tackle this one.

@jesseduffield
Copy link
Owner

go ahead @gusandrioli :)

@pythoninthegrass
Copy link
Author

Appreciate the follow-up! 🙏

@gusandrioli
Copy link
Contributor

@pythoninthegrass PR was merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants