17

When creating a new ASP.NET Core 3 project in Visual Studio for Mac, and then right clicking the project and selecting Add - Docker Support, IDE add docker-compose project to the solution and scaffolds the dockerfile for the API project.

docker-compose has the following entry by default:

services:
  project-name:
    image: ${DOCKER_REGISTRY-}projectname
  ...

It works out of the box, dockerfile gets processed, compose is called, all good. But what entity during the "compose up + debug" process defines the value for DOCKER_REGISTRY variable?

Pang
  • 9,073
  • 146
  • 84
  • 117
Maxim V. Pavlov
  • 9,983
  • 14
  • 69
  • 169

1 Answers1

7

It is an environment var on your pc or remote server, try to type :

$ echo $DOCKER_REGISTRY

the docker entry means "If variable DOCKER_REGISTRY is not set or null, use default", then it is prepended to your project name.

See https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02 for parameters expansion

kitensei
  • 2,440
  • 2
  • 37
  • 66
  • I think this isn't quite correct. `${DOCKER_REGISTRY-}` will only test for a value of `DOCKER_REGISTRY` not being set, and will not test if it's null, according to this - https://stackoverflow.com/a/32675207/1549918. So in theory, the default value for `DOCKER_REGISTRY` will only be used if the environment variable isn't set. – Chris Halcrow Mar 22 '22 at 00:05
  • See also: https://docs.docker.com/compose/compose-file/#interpolation – Wouter May 02 '22 at 15:29