title: How to have a url as image name in a docker-compose file
body: <p>I'm trying to write a docker-compose file that will build and push a versioned (1.0, 1.1...) and latest build of my image to my local v2 docker registry. However when I run <code>docker-compose build</code> I get the following error:</p>
  <pre><code>ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
  </code></pre>
  <p>I found a lot of people complaining about this error for many different reasons, in my case it has nothing to do with permissions or weather or not the docker service is running, I narrowed it down to my image naming having a URL on it (the URL of my local registry), I know that because if I name my image normally (like '/app:latest'), then the commands runs fine. So how can I have a URL as the image name?</p>
  <p>Here is what I'm trying to do (docker-compose.yaml):</p>
  <pre class="lang-yaml prettyprint-override"><code>version: &quot;3.8&quot;
  
  x-marvin-backend: &amp;default-marvin-backend
    container_name: marvin_backend
    build: ./marvin-api
    image: &quot;http://my_registry_url:5000/marvin/backend:latest&quot;
    ports:
      - &quot;3000:3000&quot;
    networks:
      - backend
  
  x-marvin-frontend: &amp;default-marvin-frontend
    container_name: marvin_frontend
    image: http://my_registry_url:5000/marvin/frontend:latest
    build:
      context: ./marvin-front
      args:
        - REACT_APP_SERVICES_HOST=http://marvin_backend:3000/
    ports:
      - &quot;80:80&quot;
    networks:
      - backend
    depends_on:
      - backend
  
  services:
    backend: *default-marvin-backend
  
    backend_versioned:
        &lt;&lt; : *default-marvin-backend
        image: http://my_registry_url:5000/marvin/backend:1.0
  
    frontend: *default-marvin-frontend
  
    frontend_versioned:
        &lt;&lt; : *default-marvin-frontend
        image: http://my_registry_url:5000/marvin/frontend:1.0
  
  networks:
    backend:
  </code></pre>
  <p>I'm new to docker in general, my main goal here is to have a simple, preferably one command (e.g <code>docker-compose build</code>), that will build and tag both my front end and back end images so that I can just execute <code>docker-compose push</code> to push those newly created images to my registry running on AWS. With that I also want to be able to override the latest version of those images in the registry while also adding a versioned image for backup purposes, in case I want to revisit any of those version in the future.</p>
  <p>Then in the AWS EC2 machine I have another <code>docker-compose.yaml</code> file that just fetches the latest versions of both images and run their containers.</p>
  <p>So to summarize I would develop the application on my local machine, then add the new version manually to the versioned services in the local <code>docker-compose.yaml</code> file, then run <code>docker-compose build</code> followed by <code>docker-compose push</code>; then ssh into my AWS machine and run <code>docker-compose up</code> to fetch the latest and newly updated images and run them.</p>
  <p>This could later evolve into a CI/CD pipeline, but right now I'm taking baby steps and trying to get my image name to have a URL in it.</p>
  <p>Thank you.</p>
  <h2>Edit</h2>
  <p>I tried using a <code>.env</code> with <code>REGISTRY=http://my_registry_url:5000/marvin</code> and then using <code>image: &quot;${REGISTRY}/frontend:latest&quot;</code> or <code>image: &quot;$${REGISTRY}/frontend:latest&quot;</code> but that also didn't work</p>