28

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?

2

2 Answers 2

11

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

3
9

From the documentation: https://docs.docker.com/compose/compose-file/#interpolation

${VARIABLE-default} evaluates to default only if VARIABLE is unset in the environment.

In the case of your generated file ${DOCKER_REGISTRY-}projectname

  • If DOCKER_REGISTRY is set, say to "docker.io/"
    • The image name would be "docker.io/projectname"
  • If DOCKER_REGISTRY is NOT set
    • The image name would be "projectname"
      • This shorthand name, also defaults to docker registry so you won't see difference unless you set DOCKER_REGISTRY to something other than the default registry.

what entity during the "compose up + debug" process defines the value for DOCKER_REGISTRY variable?

I don't think it is defining a value for the variable. It is setting your compose file to SUPPORT the setting of using DOCKER_REGISTRY to consistently control same registry for all images used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.