I'm learning docker
I need to specify the working directory for a docker image, I think that'll be something like this:
version: '2' services: test: build: context: ./dir
Now I want to make the image python:onbuild
to run on the ./dir
, but I dont want to create any Dockerfile
inside the ./dir
.
The docker-compose
manual says nothing about that.
Is it possible? How to do that?
context (REQUIRED) context defines either a path to a directory containing a Dockerfile, or a url to a git repository. When the value supplied is a relative path, it MUST be interpreted as relative to the location of the Compose file.
WORKDIR is your working directory. It only exists in your container.
WORKDIR. The WORKDIR instruction sets a working directory for other Dockerfile instructions, such as RUN , CMD , and also the working directory for running instances of the container image.
I think you're looking for working_dir
. Search for "working_dir" in the docker-compose reference.
You can specify the working directory as follows.
version: '2' services: test: build: context: ./dir working_dir: /dir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With