Reuse image built by one service in another service

Docker Compose builds your image with the name proj_master, beacuse you did not specify an image name under your master service in the Compose file.

You have a build section, so Docker Compose will build the image and give it a name based on your <directory_name_where_you_run_compose>_<service_name>:latest. I did not find this in the documentation, but tried with one of my projects, and it’s in line with what you experienced.

You can fix your project by specifying the image name in your Compose file and using the same image for both services:

version: '3'


services:

  master:
      build: docker/myservice
      image: username/masterimage:version


  slave:
      image: username/masterimage:version
      depends_on: master

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)