I'm running Docker CE in Ubuntu 16.04. I've created a Docker image for the polymer-cli. The idea is to be able to run polymer commands from inside disposable docker containers using bash aliases that mount the current directory, run the command and then destroy the container, like this:
docker run --rm -it -v $(pwd):/home/node/app -u node fresnizky/polymer-cli polymer
This works perfectlty, but if I create a bash alias for this command:
alias polymer="docker run --rm -it -v $(pwd):/home/node/app -u node fresnizky/polymer-cli polymer "
Then $(pwd) points to my home directory instead of my current directory.
Anyone knows how I can solve this?
The problem is that, as you have used double quotes, the command substitution is being done at the time of alias declaration, not afterwards.
Use single quotes:
alias polymer='docker run --rm -it -v $(pwd):/home/node/app -u node fresnizky/polymer-cli polymer'
Also, instead of using the pwd command substitution, $(pwd) you can use the environment variable PWD expansion, $PWD, which will expand to the same value. In fact, pwd command also gets its value from the PWD variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With