Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

docker-compose up load build definition error

I am developing a docker-compose.yml file that looks like so:

version: '3.9'
services:
 web-app: 
   build: ./my-frontend-app.Dockerfile
   ports:
     - "4200:4200"

When I run docker-compose up, I get the following error:

failed to solve with frontend dockerfile.v0: failed to read
dockerfile: error from sender: walk
/Users/daniel/My_Projects/my-frontend-app/my-frontend-app.Dockerfile:
not a directory ERROR: Service ‘web-app’ failed to build : Build
failed

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So it failed to build because it cannot locate the directory my Dockerfile is in?

>Solution :

If you use Compose build: with just a string, that string is interpreted as a directory name, and the Dockerfile is assumed to be in a file named exactly Dockerfile in that directory. There is an extended form of build: that lets you specify a dockerfile: within the build context.

version: '3.8'
services:
 web-app: 
   build:
     context: .
     dockerfile: my-frontend-app.Dockerfile

(If you can use all default options – you can use the default dockerfile: Dockerfile and do not need args: or any other special build-time options – I tend to prefer the short build: ./directory-name/ syntax, but it won’t work in your case when you have multiple Dockerfiles.)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading