Skip to content

docker run add shortcut for mounting PWD #3046

Description

@roubles

Description

docker run is a very powerful way to make scripts platform independent. Unfortunately the only way to pass files to a docker run is via a volume mount.

So when I have a script that works as follows:

my-awesome-script --file ./path/to/some/file

The dockerized version of calling that script becomes this monstrosity:

docker run -i -v $(pwd):/mnt containers.example.com/foo/my-awesome-script-img --file /mnt/path/to/some/file

#1273 adds support for mounting relative paths. The ask for this enhancement is to provide a shortcut (say -x) that automounts the pwd, making all files available within the docker at the same relative path location, so, the call to the dockerized version of the script could simply be:

docker run -ix containers.example.com/foo/my-awesome-script-img --file ./path/to/some/file

This will make docker run even more convenient/powerful.

This is a very frequent usecase that comes up on SO:
https://stackoverflow.com/questions/41092587/passing-file-as-argument-to-docker-container
https://stackoverflow.com/questions/44421635/how-to-get-docker-container-to-read-from-stdin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions