How could you name your docker images based on directory name?

  bash, docker, dockerfile

I’m looking to use docker more frequently, and I ended up with a template directory structure a bit like:

    |- Dockerfile
    |- src/...

Where & are just the usual docker build -t my-new-project . and docker run -p 8888:8888 -v $(pwd):/workdir my-new-project

However, I need to modify the image name in & for every new project – how could I use bash to set the image name based on the directory basename.

Also, if there are best practices against doing what I’m doing please let me know.

Source: Docker Questions