Unable to run docker build inside docker run

Viewed 32

I am trying to build an image and then run it in one command. Using stackoverflow question I have menaged to scrape this command:
docker run --rm -it -p 8000:8000 -v "%cd%":/docs $(docker build -q .)

However it produces an error:

docker: invalid reference format.
See 'docker run --help'. 

First part of the command ( docker run --rm -it -p 8000:8000 -v "%cd%":/docs .) works properly on already built image the problem lies inside $(docker build -q .). Dockerfile is inside the folder I have opened in cmd.

1 Answers

You need to run it in PowerShell, not cmd.

Try docker run --rm -it -p 8000:8000 -v ${PWD}:/docs $(docker build -q .).

Related