375

I was trying to build my Docker image for my Gatsby application. Whenever I run the command docker build . -t gatsbyapp, it gives me an error:

failed to solve with frontend dockerfile.v0: failed to build LLB:
failed to compute cache key: "/.env" not found: not found

Meanwhile my Dockerfile is shown below:

FROM node:13

WORKDIR /app

COPY package.json .

RUN yarn global add gatsby-cli

RUN yarn install

COPY gatsby-config.js .

COPY .env .

EXPOSE 8000

CMD ["gatsby","develop","-H","0.0.0.0"]
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Muhammad Yasir
  • 3,814
  • 2
  • 5
  • 8
  • 2
    I'm VTC this question as needs more focus. There are lots and lots of reasons why you may be getting this error, look at the multiple completely different answers below. – Liam May 07 '21 at 15:24
  • 1
    This question needs more detail. does the .env file actually exist or not? – Storm Muller Oct 28 '21 at 21:51
  • One of the reasons can be permission of the docker file. Folks getting error also check for error message, "SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permi ssions for sensitive files and directories." – infiniteLearner Dec 11 '21 at 11:07
  • 1
    I too faced the problem. I forgot to save the Dockerfile after copy the example content to the file window in vscode, once the Dockerfile is saved , the error Dockerfile can not be empty error gone and it worked. – user28186 Jul 28 '22 at 13:08

57 Answers57

423

I had experienced this issue after upgrading to the latest Docker Desktop version on Mac. Solved with the comment on this issue.

Solution: Don't use buildkit and it works for me.

export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Esteban Gatjens
  • 4,651
  • 1
  • 14
  • 8
  • 24
    Or `DOCKER_BUILDKIT=0 docker build ...` – Ari Seyhun May 21 '21 at 15:10
  • 31
    If someone facing the issue with docker desktop 3.6.0 and docker engine v 20.10.8 in Windows 10 OS. I set the buildkit flag (at settings=> docker engine =>features json node => buildkit attribute in the json) to false and recolved the same problem.. – Satheesh K Sep 15 '21 at 11:42
  • 11
    On Docker for Windows this option can be found in Settings -> Docker Engine -> buildkit = false – dima_horror Nov 29 '21 at 10:27
  • If you have Docker Desktop installed on your machine, you can also set the `buildkit` option to `false` in Docker Engine's configuration, as mentioned in [this comment](https://github.com/docker/compose/issues/8449#issuecomment-1053976009). – Long Nguyen Apr 05 '22 at 12:16
  • This works for me I have run this command into the shell, For permanent solution you may need to add in .bashrc file. – Kartik Agarwal Oct 28 '22 at 06:15
  • If you're on Windows and hate the Docker GUI try this `$Env:DOCKER_BUILDKIT=0 $Env:COMPOSE_DOCKER_CLI_BUILD=0 ` – azerELweed Nov 22 '22 at 10:40
  • I solved it only by setting `export DOCKER_BUILDKIT=0` – Jakob Ojvind Nielsen Feb 14 '23 at 13:52
266

I had the same issue and all I had to do was to capitalize the Docker configuration filename:

dockerfile > didn't work

Dockerfile > did work

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Luis Gouveia
  • 8,334
  • 9
  • 46
  • 68
  • 22
    If you do not specify a docker file with the -f option, it searches for the default file "Dockerfile" in the current path. With "docker build -f dockerfile" you can choose which file is the docker file – Murmi Aug 23 '21 at 09:27
  • 1
    This pointed me in the right direction. Windows had added ".txt" to my Dockerfile. Removed that and problem solved. – rosscova Sep 20 '21 at 23:27
  • It is a good practice to always use `-f ./Dockerfile` in the build command – Eugene Gavrilov Nov 16 '21 at 13:54
  • I created a Dockerfile using text edit and it by default gives an extension : .rtf. But the mac was not showing the extension. So please make sure the Dockerfile has no hidden extensions... – Sudheer Kumar Nov 24 '21 at 16:53
  • if use `docker-compose` set dockerfile: to `Dockerfile` in `docker-compose.yaml` file – Hamed Lohi Feb 27 '22 at 10:01
134

If you use Docker for Windows you need to disable buildkit from Docker Engine in Settings. It works for me and solved my error

Set buildkit option to false.

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": false
  }
}

Docker for Windows buildkit option

f.khantsis
  • 3,256
  • 5
  • 50
  • 67
dima_horror
  • 3,098
  • 1
  • 20
  • 24
128

If you are seeing this issue it is not actually the real issue. The actual issue is nested in the error logs somewhere. To see the actual issue you need to run your build command like this:

DOCKER_BUILDKIT=0  docker build .

Notice the DOCKER_BUILDKIT=0. That will make the build kit not hide the nested error. From there you should be able to google the correct solution.

This will also make the build look different in command line, but don't worry about that. Just look for the error.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Samuel Thompson
  • 2,429
  • 4
  • 24
  • 34
  • This was really helpful but I would like to know, now that I've found the problem, how to revert to the previous state ... is it DOCKER_BUILDKIT=1 ? – glaucon Jun 22 '23 at 07:19
  • @glaucon there is nothing to revert. The command above does not really do anything other than run a build. If you run a build like normal it will overwrite the previous build. – Samuel Thompson Jul 19 '23 at 13:26
75

Probably not the problem the OP had, but I had this issue while trying to build my container running inside Windows Subsystem for Linux (WSL) (Debian WSL2), just after having freshly installed Docker Compose and all I had to do was close the (Debian) terminal and reopen it and my issue was solved.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jeffresc
  • 884
  • 6
  • 9
  • 4
    which terminal and what window? – Boppity Bop Dec 03 '20 at 13:59
  • 2
    Yes, more elaboration on this would be helpful, I'm using wsl and this works in a vm, but not in wsl. – eskers Dec 16 '20 at 04:04
  • 3
    In a windows host, WSL(Windows Subsystem for Linux) provides a way to run linux based commands. This is done by executing commands from a shell (Linux like) in windows. I had the same issue. Closing the shell and opening it again solved it. – Paramveer Singh Dec 18 '20 at 15:42
  • In my case, (on my Windows 10 PC) I didn't have WSL running, but I had multiple CMD windows open and also the Microsoft terminal BUT, I was running `docker build` from VSCode terminal. After I closed the Microsoft Terminal and the CMD windows, it began to work. – Anonymous Person Jul 21 '21 at 09:17
  • I'm using WSL2 (Ubuntu) with Windows 10 and using the VSCode terminal (zsh). I configured the launch.json & task.json so i can run my application with a single click form VSCode but got that error message. I only had to re-start my VSCode and suddenly worked. – Xotl Aug 28 '21 at 19:59
  • Thanks, how stupid it is... I even tried to re-install Docker Desktop but finally just closing my shell and open another one was fixing it. Note that I use WSL 2 with Ubuntu 20.04 but I think this is mainly an issue with WSL 2 and not related to the Distro. – рüффп Jan 14 '22 at 10:20
43

If you are using Docker Desktop, restarting Docker worked for me. TroubleshootRestart

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Madupoorna
  • 575
  • 4
  • 5
  • 2
    Troubleshoot -> Restart is not a valid docker command. Please try and answer with valid commands that can be run in the terminal. – marcogmonteiro Nov 09 '20 at 09:29
  • 23
    Monarindu meant to do this is in UI level of Docker Desktop. You can right click in the Docker logo (found in the icons of system tray), and select Restart Docker option or select Troubleshoot and click Restart in popped up UI window. If you need command line workarounds, please check this [https://forums.docker.com/t/restart-docker-service-from-command-line/27331/6] – Nilucshan Siva Jan 16 '21 at 08:03
  • Restarting Docker didn't help. I also had to restart WSL. From powershell running wsl --shutdown – Andis Apr 14 '22 at 12:27
  • I did not find **Troubleshoot → Restart**, but your **Restart** idea did work. ✌ – User Apr 18 '22 at 11:19
  • I had to restart my machine but it did work. I did not set the [buildkit= false] option that other answers here are recommending. – umbersar Dec 11 '22 at 00:33
35

I have the same issue.

Docker filename:

  • DockerFile - error
  • dockerFile - error
  • Dockerfile - work!

You need only one capitalized character.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Liar Рonest
  • 661
  • 6
  • 5
21

If you are using Docker Desktop for Mac or Windows, you might have to also disable it in your 'Docker Engine' JSON configuration.

Docker Desktop → SettingsDocker Engine → change the "features": { buildkit: true} to "features": { buildkit: false}.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
18

I don't remember where exactly I read this, but if you are using WSL2 and receive that error, then delete the Docker configuration file in your WSL2 home folder and try to rebuild your image.

That is if you have already checked your file names and reconfirmed that everything is named correctly (Dockerfile, .dockerignore, etc.)

WSL2 Ubuntu:

rm ~/.docker/config.json
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Georgi Yanev
  • 191
  • 1
  • 4
  • This is what worked for me. Also, the contents of my `~/.docker/config.json` file was only `{ "credsStore": "desktop.exe" }`. I'm guessing that this is the culprit. So maybe check your config file and make sure you aren't deleting other setttings that you might need. – treckstar Jan 09 '23 at 19:14
15

In my case I was trying to copy over folder wp-content from my current directory, inside the Docker image I was building. Like so:

FROM wordpress:latest

# Copy wp-content
COPY ./wp-content/ ./var/www/html/wp-content/

However, I noticed that I had a .dockerignore file, which explicitly was told to ignore wp-content.

When I removed wp-content/ from .dockerignore it worked fine.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
FooBar
  • 5,752
  • 10
  • 44
  • 93
12

In my case, I had an extra space after "." in the context option:

docker build -t myapp .[EXTRA_SPACE_HERE]
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Bilal Ch
  • 358
  • 4
  • 15
  • 3
    Why would that matter? The shell wouldn't even pass the extra space to the `docker` binary unless you quote it (`". "`). – Robert Mar 23 '21 at 19:16
  • Are you sure it was a normal space? Not some Unicode thingy? [NO-BREAK SPACE](https://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=0x), [hair space](https://en.wikipedia.org/wiki/Whitespace_character#Unicode), EM SPACE, or similar? – Peter Mortensen Jan 04 '22 at 00:21
  • @PeterMortensen it was a normal space as I was executing this command on terminal directly. I don't remember correctly if I typed all that in or did I copy it from somewhere. – Bilal Ch Jan 06 '22 at 14:11
10

Disable the macOS v11 (Big Sur) virtualization framework:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tudor
  • 1,510
  • 1
  • 18
  • 17
9

Make sure your .dockerignore doesn't match your file.

A pattern sometimes used with .dockerignore is to add a wildcard to it and exclude the specifically expected file to the context with !filename syntax. EG:

*
!Cargo.toml
!Cargo.lock
!src
!setup.py
!README.md
!project
!requirements
__pycache__

If you later try to use a file in Dockerfile it will match the wildcard and not be present in the context. Add an exception to the new file or remove the wildcard to fix this.

chicocvenancio
  • 629
  • 5
  • 14
7

In my case

failed to solve with frontend dockerfile.v0: failed to create LLB definition: no build stage in current context

was caused by setting ENV before FROM. Probably this is not allowed for some Dockerfile instructions. After moving ENV right after FROM the error is gone.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
sarh
  • 6,371
  • 4
  • 25
  • 29
6

My problem was due to using VPN.

parsa
  • 987
  • 2
  • 10
  • 23
5

I had a typo,

FROM apline:3.7 instead of FROM alpine:3.7.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
techkuz
  • 3,608
  • 5
  • 34
  • 62
5

I faced the issue due to VPN connectivity.

All I had to do was set a manual proxy in the Docker Desktop PROXIES section:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abhishek D K
  • 2,257
  • 20
  • 28
5

In my case, this was because of the under-expressed use cases from documents. Almost all examples tell you to use . and Dockerfile (capital D), but they mostly do not tell explicitly how to customize.

docker image build --tag any_image_tag --file any_file_name path_to_your_context_folder

This one is better in my opinion, and I hope it will help those coming here. any_file_name is really any file name with build instructions in it. "dockerfile" in it is not needed, but it helps to identify and give the full path if it differs from the context folder. path_to_your_context_folder is basically where your work resides, such as a web application.

For example, the following is my current test in windows where COPY . /app uses the context folder as the .:

docker image build --tag nested_image --file C:\WorkSpace\myapp\dockerfiles\any_file_name C:\WorkSpace\myapp\contextfiles\

PS: The topic really has interesting answers to the same problem, but by lots of exotic causes. Mine is just a side note to a hidden-in-plain-sight problem.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yılmaz Durmaz
  • 2,374
  • 12
  • 26
5

Try with this simple solution, name your dockerfile like this Dockerfile with no extension.

Ahmer Saeed
  • 576
  • 5
  • 13
5

It was solved for me

I was using a MacBook Air (M1) and had an issue, because I was using an image which supported linux/amd64 and my system architecture was arm64.

So make sure to run the compatible image based on your device.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
abhishek
  • 69
  • 1
  • 2
  • Yup this was it for me I had to add `FROM --platform=linux/amd64` followed by the image name – nmu Apr 08 '23 at 13:12
4

I had to set "credsStore": "" in my ~/.docker/config.json .... It was previously set to credentials.exe.

In WSL2 ddev start fails at docker-credential-desktop.exe, "error listing credentials" #2342

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
3

I got this issue when I'd run out of disk space, presumably exacerbated by the numerous image layer caches building up as I teased and tweaked my Dockerfile.

Claire Furney
  • 2,115
  • 3
  • 24
  • 36
3

In case your Docker file is in a different path with a different name than Dockerfile you can run

docker build -t build_tag_name -f './path/to/dockerfile/exampledockerfile' .
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Affes Salem
  • 1,303
  • 10
  • 26
3

For me, I found that I was trying to build from the wrong directory.

Cyebukayire
  • 795
  • 7
  • 14
3

In my case, I had 2 images, and I was copying from the same image. My specific error was: failed to solve: failed to solve with frontend dockerfile.v0: failed to create LLB definition: circular dependency detected on stage: kubexit

FROM karlkfi/kubexit:latest AS kubexit
COPY --from=kubexit /bin/kubexit /bin/

FROM maven:3.8-jdk-11-slim AS build

So it was a circular reference. The fix:

FROM karlkfi/kubexit:latest AS kubexit

FROM maven:3.8-jdk-11-slim AS build
COPY --from=kubexit /bin/kubexit /bin/
tom
  • 1,331
  • 1
  • 15
  • 28
2

In my case, I had two problems:

  1. I missed the . in the end of the command that gives the context option, and
  2. I have a ".txt" extension in the file name of the Dockerfile.

After these two adjustments, all worked as expected.

2

Sometimes this kind of error comes from a stupid syntax error... In my case I modified a Dockerfile and removed some environment variables, but forgot to take off the backslash from the last line...

    WORDPRESS_HTTPS_PORT="8443" \
    WORDPRESS_HTTP_PORT="8080" \
    WORDPRESS_SKIP_INSTALL="yes" \ <-- to be removed

EXPOSE 8080 8443
USER 0
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Francois
  • 139
  • 3
  • 15
2

Make sure that you are using the same platforms, e.g. if you build the first image (my-custom-service) with

FROM --platform=linux/amd64 node:14

then you need to add the --platform to other Dockerfiles that use the baseimage of the first:

FROM --platform=linux/amd64 my-custom-service
Joe
  • 272
  • 2
  • 9
2

For me the following was the error:

failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head https://registry-1.docker.io/v2/library/postgres/manifests/13-alpine: net/http: TLS handshake timeout

I am using WSL2 in Windows 10 and Docker Desktop and I got this issue after updating the Docker Desktop to version 3.5.

I fixed the issue by enabling the WSL integration with additional distributions.

To enable it:

Open Docker Desktop in Windows and go to settingsResourcesWSL IntegrationEnable integration with additional distributions and enable it for the Ubuntu application that you installed.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vishnu KR
  • 718
  • 1
  • 8
  • 22
2

I had the same error, but by moving the Dockerfile out of the sub-folder and into the root folder of my application. It fixed the error message.

Sebastian
  • 402
  • 3
  • 12
2

If you use Docker for Windows, then be sure that the Docker engine is set to the mode matching the image you want to build (Windows / Linux).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Eric
  • 49
  • 4
2

I had the same issue while building a Docker image through Visual Studio 2019. My Docker file had a name like Dockerfile.

Dockerfile > didn't work

dockerfile > did work

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
MadanD
  • 107
  • 5
2

If you are using any new features that are not supported in v0 Dockerfile (like multiple build contexts), you need to specify Dockerfile version at the start of Dockerfile

For example in Dockerfile, first line would be:

#syntax=docker/dockerfile:1.4

Andrius
  • 19,658
  • 37
  • 143
  • 243
1

Chiming in with another possibility that happened to me: If you're using build stages, make sure that you have the right stage names throughout.

I had a stage defined with

FROM zzz AS development

that was later used for another stage

FROM development AS yyy

On a whim I changed development to dev, but only in the first instance. So the latter one was still FROM development while the former was AS dev.

Odd how arcane the error message is for a such a minor mistake... You'd think they could just have the error message say "couldn't find development" or something.

rococo
  • 2,280
  • 2
  • 22
  • 37
1

I ran into this problem using WSL2 Ubuntu, and I fixed it by changing the permissions of the Dockerfile.

When I set up WSL2 on my computer I copied some of my files (including the Dockerfile) directly from Windows into the Ubuntu root folder, which apparently results in files with blank permissions:

---------- 1 user user 10M Jan 1 00:00 Dockerfile

To fix it I ran chmod 644 Dockerfile:

-rw-r--r-- 1 user user 10M Jan 1 00:00 Dockerfile

And after that Docker was able to build the image without any further issue.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
James Douglas
  • 3,328
  • 2
  • 22
  • 43
1

In my case I was not in the same directory as the dockerfile itself.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1

I solved this problem by just adding sudo (Ubuntu) at the head of the build command. For example:

sudo docker build --tag somename .
Younes Belouche
  • 1,183
  • 6
  • 7
1

All it took for me was adding --no-cache as an argument to the build.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
curiousity
  • 79
  • 7
1

For Me

I Opened Docker Desktop->open settings->Docker Engine->

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": false
  }
}

Here My default value of buildkit is true -> i changed to false and restart the docker engine

that worked for me

Reshnu chandran
  • 338
  • 2
  • 6
1

With the docker desktop this issue is usually solved by adding -f option. for example : Let your docker file is placed at c:\Dockerfile.txt

you can run the following command to build the image

docker build -f "c:\Dockerfile.txt"

1

None of the other answers worked for me. In my case the problem was I had some permission issues with docker in CLI and rather than fixing it I was just using sudo. So I fixed those permission issues (in the ~/.docker/buildx folder) and ran docker without sudo and it worked.

Sherwin Zadeh
  • 1,339
  • 15
  • 17
0

If you are using Windows Subsystem for Linux (WSL), check if Docker is running before you launch the window. If you have started Docker after starting the window. Then Just restart your terminal. And it should work if your file is correct.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Avinal
  • 184
  • 4
  • 11
0

Specify the proxy server by setting the HTTP_PROYY and HTTP_PROXYS environment variables.

Example:

http_proxy=http://username:password@proxy.example.com:8080
https_proxy=http://username:password@proxy.example.com:8080
sos418
  • 782
  • 8
  • 13
0

As far as I can see, this error can have many reasons.

In my case, there were two errors: (1) in the Dockerfile: the # syntax = ***** line was incorrectly spelled out and (2) in file docker_compose.yaml, the web / build: * line was pointing to the wrong directory.

I was helped by reading the Dockerfile documentation and taking a break to regain attention.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kokserek
  • 530
  • 8
  • 21
0

In my case, I had to uninstall Astrill VPN.

ZhefengJin
  • 930
  • 8
  • 17
  • You are right, it's an issue with the VPN for me as well. We don't need to uninstall the VPN, just disconnect. Or else, you can do the proxy setup as well. Check this answer : https://stackoverflow.com/a/68140590/3962816 – gaurav kumar Aug 01 '21 at 09:07
0

I've had this issue/error before when I had a script that I used to build multiple Dockerfiles and where one of the Dockerfiles was commented out. Once I uncommented the Dockerfile and run the script again it worked fine for me.

OpenBSDNinja
  • 1,037
  • 10
  • 18
0

In case you have a similar project structure,

├── docker
│   │
│   ├── app
│   │   └── Dockerfile
│   └── mlflow
│       └── Dockerfile
│
└── docker-compose.yml

you might be missing to specify the build: context in the docker-compose.yml:

version: '3'

services:

  mlflow:
    build:
      context: ./
      dockerfile: ./docker/mlflow/Dockerfile
    container_name: ml_app_mlflow
    volumes:
      - ./db:/db
    ports:
      - 5000:5000
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Miguel Trejo
  • 5,913
  • 5
  • 24
  • 49
0

In case you previously executed docker buildx install, your docker command is aliased to docker buildx, which is based on Docker Buildkit, which is currently not supported (sadly) for Windows containers.

To remove the alias, execute the following command:

docker buildx uninstall

I hope that will save time to people like me, who forgot about this alias

Meir Gabay
  • 2,870
  • 1
  • 24
  • 34
0

Yet another possibility: I was using Linux-based containers on Windows 10 for WSL when trying to build a Dockerfile with a Windows 10 servercore image.

In the system tray, right-click Docker Desktop and select Switch to Windows containers...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
slayer
  • 643
  • 7
  • 14
0

I had the same issue while using visual studio 2022. The problem was that visual studio 2022 make a logical directory structure which was different from the physical directory structure. So the file was physically not present at the location where visual studio 2022 was showing.

Once the correct location was specified, it works fine.

I did not have to change DOCKER_BUILDKIT=0 or any settings. But used -f option to specify the docker file.

iaq
  • 173
  • 1
  • 2
  • 10
0

The issue was fixed for me after removing the "LABEL" Instruction & its Argument in my Dockerfile

LABEL maintainer="yureshcs@gmail.com"

Yuresh Karunanayake
  • 519
  • 1
  • 4
  • 10
0

Try removing your comments and run again, It worked for me

Pedro Azevedo
  • 55
  • 1
  • 9
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 10 '23 at 04:00
0

I got a similar output. Turns out I exported USER='' in my .zshrc. Exporting a value there fixed the issue: USER='yourname'

[...]
Failed to fire hook: while creating logrus local file hook: user: Current requires cgo or $USER set in environment
[2023-02-27T11:20:07.698673000Z][docker-credential-desktop][F] user: Current requires cgo or $USER set in environment
[common/pkg/paths.Home()
[   common/pkg/paths/paths.go:105 +0x54
[common/pkg/paths.Container()
[   common/pkg/paths/user_darwin.go:30 +0x1d
[common/pkg/paths.Data()
[   common/pkg/paths/paths_darwin.go:27 +0x19
[+] Building 1.0s (3/3) FINISHED
 => [internal] load build definition from Dockerfile                                                                                       0.1s
 => => transferring dockerfile: 37B                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                          0.0s
 => => transferring context: 2B                                                                                                            0.0s
 => ERROR [internal] load metadata for docker.io/library/node:16-buster                                                                    0.8s
------
 > [internal] load metadata for docker.io/library/node:16-buster:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exit status 1, out: ``
Colin
  • 1,112
  • 1
  • 16
  • 27
0

I had a symlink to the directory I was running docker build from. Make sure you cd into the actual path of the directory your Dockerfile is in, and not run it from a symlink path.

Zoltán
  • 21,321
  • 14
  • 93
  • 134
0

Is my case it was because the applications defined in a docker-compose file did not have individual Dockerfiles, but was sharing the same Dockerfile. After defining in docker-compose.yml:

build:
  dockerfile: <RELATIVE_PATH_TO_THE_DOCKER_FILE>

In each of the apps build section, it is building correctly.

Jesper Paulsen
  • 311
  • 3
  • 8
-1

In my case it worked after I've restarted the VPN connection.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
-1

This is simple actually, if you will read full error solution is there only:

error says: failed to solve with frontend dockerfile.v0: failed to read dockerfile, it means it is looking for docker file which is named as dockerfile, so chances maybe you renamed or have created your Docker file with some different name.

Deepanshu Mehta
  • 1,119
  • 12
  • 9