I've just started to use Docker.
I'm working on a project coded by another developer. In the project Docker container, I have three micro-services (aggregatore, classificatore, testmicro).
In classificatore/
, I have:
classificatore/Dockerfile
FROM python:3
RUN mkdir /src
ADD requirements.txt /src/.
WORKDIR /src
RUN pip install -r requirements.txt
ADD . /src/.
RUN mkdir -p /tmp/reqdoc
CMD ["python", "main.py"]
I build-up the app by running:
docker-compose up -d
I've realised that Docker is not compiling the source files in the project folder but it is using the ones in the dir /src
created by classificatore/Dockerfile. I can't find this dir.
How can I tell docker to use the files in my project location?
I'm using PyCharm, don't know if it is an useful info :-)
EDIT 1:
docker-compose.yml
version: '2.1'
services:
files:
image: busybox
volumes:
[..]
grafana:
[..]
prometheus:
[..]
aggregatore:
[..]
classificatore:
build: classificatore/.
volumes:
- [..]
volumes_from:
- files
ports:
- [..]
command: ["python", "/src/main.py"]
depends_on:
rabbit:
condition: service_healthy
testmicro:
[..]
rabbit:
[..]
docker-compose up -d
will build an image for services that declare a build if and only if no image exists already in your local docker registry. If youdocker-compose down
and start over, the next call will simply start containers with the already existing image.To update an existing image and run a new container out of it, you have to specifically ask for a build.
An other options is to use the
--build
option.You might find other useful scenarios by inspecting the help: