Why docker-compose builds service that is overridden with image?

I’m struggling to understand what actually happens when I’m overriding services in docker-compose.

I’m talking about situation in which I have docker-compose.yml and docker-compose-dev.yml present.

I’m running like this: docker-compose -f docker-compose.yml -f docker-compose-dev.yml run hello

# Dockerfile
FROM library/hello-world

ADD this-file-dos-not-exist /var
# docker-compose.yml
version: '2'


    build: .
# docker-compose-dev.yml
version: '2'


    image: library/hello-world

What I expected to happen was that docker-compose will run hello services based on image from docker-compose-dev.yml. What actually happens is that docker-compose for no reason tries to build image based instructions from docker-compose.yml (it will not use this image to run hello service anyway):

$ docker-compose -f docker-compose.yml -f docker-compose-dev.yml run hello
Creating network "tmp_default" with the default driver
Building hello
Step 1/2 : FROM library/hello-world
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest
 ---> 48b5124b2768
Step 2/2 : ADD this-file-dos-not-exist /var
ERROR: Service 'hello' failed to build: lstat this-file-dos-not-exist: no such file or directory


So why this is being built if it’s not going to be used?

In my case this is really problematic because on first run dev has to wait a lot for no reason for image to be build.

What I’d expect is that if service is overridden in following docker-compose-* file only new image will be downloaded.

Am I missing something here?