what is docker run -w flag?

Viewed 3413

Came across a docker run command that uses -w flag.

docker run -v $(pwd):/project \
         -w /project \
         -p 8081:8081 \
         gcr.io/base-project/myoh:v1

Any idea what the -w flag is for?

2 Answers

Is used for set working directory (-w)

 docker  run -w /path/to/dir/ -i -t  ubuntu pwd

The -w lets the command being executed inside directory given, here /path/to/dir/. If the path does not exist it is created inside the container.

Related