Bill Door
Bill Door

Reputation: 18946

How do share a directory with same name in the current directory with docker

I would like to share the current directory with a docker container and have the docker containers current directory be that directory.

docker run --volume "$(pwd):/$(basename $(pwd)) container parameters

will share the current directory with the container at the root directory. But how can I have the current directory for the container be the same directory?

What am I really trying to do?

I am using docker containers to isolate executable programs. The program I am working with uses the name of the current directory as a "default" parameter. So, I would like the current directory when the container is run to be the shared directory. It is important that the name of the directory be correct. That is the name of the directory cannot be a fixed name.

The container is set to execute the command, so I don't think there is a way to cd before the default command is executed.

Thanks for any docker volume insight.

Upvotes: 1

Views: 163

Answers (1)

Bill Door
Bill Door

Reputation: 18946

Answering my own question.

Add --workdir /$(basename $(pwd)).

Brilliant!

Upvotes: 1

Related Questions