Context or workdir for docker-compose

I am learning docker

I need to specify the working directory for the docker image, I think it will be something like this:

version: '2' services: test: build: context: ./dir 

Now I want to make a python:onbuild to run in ./dir , but I do not want to create any Dockerfile inside ./dir .

The docker-compose manual doesn't say anything about this.

Is it possible? How to do it?

+21
docker docker-compose
source share
3 answers

I think you are looking for working_dir . Find "work_dir" in the link to the docker link .

+67
source share

Docker Compose build configuration ends when you call docker build , so you need to have a Docker file to use this workflow.

As docs tells python: onbuild , you can start with a minimal Docker file that just contains FROM python:onbuild . But, as they also say :onbuild not a great option, you will have much more control over creating your own FROM python Dockerfile FROM python .

+3
source share

You can specify the working directory as follows.

 version: '2' services: test: build: context: ./dir working_dir: /dir 
0
source share

All Articles