Why Docker is not compiling my micro-service sourc

2019-08-14 14:05发布

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
1条回答
叼着烟拽天下
2楼-- · 2019-08-14 14:27

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 you docker-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.

docker-compose build
docker-compose up -d

An other options is to use the --build option.

docker-compose up -d --build

You might find other useful scenarios by inspecting the help:

docker-compose --help
docker-compose build --help
docker-compose up --help
查看更多
登录 后发表回答