Docker $(pwd) and bash aliases

Viewed 11296

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?

2 Answers

Just want to share, for those who have issue with $PWD on Windows, cuz it will show just empty, my TL came with great solution for all platforms:

docker run --rm -it -v ${PWD:-.}:/home/node/app -u node fresnizky/polymer-cli polymer

Related