Build failed with error failed to solve failed to read dockerfile

Behaviour when using custom docker file names the action fails . buildx call failed with: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to re...

Behaviour

when using custom docker file names the action fails .

buildx call failed with: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /tmp/buildkit-mount967127233/build.Dockerfile: no such file or directory

Steps to reproduce this issue

when the value of the file key is set to ./Dockerfile it works when is set to ./build.Dockerfile it fails.

Expected behaviour

The action should be able to use a custom file name ./build.Dockerfile

Actual behaviour

buildx call failed with: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /tmp/buildkit-mount967127233/build.Dockerfile: no such file or directory

Configuration

  • Repository URL (if public):
  • Build URL (if public):
jobs:
  build:
    name: Build App
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Set Env Values
        run: |
          git_commit_short=$(git rev-parse --short HEAD)
          echo "GIT_COMMIT_SHORT=$git_commit_short" >> $GITHUB_ENV
          git_url=$(git config --get remote.origin.url | sed "s/git@//g;s/.git//g;s/:///g")
          echo "GIT_URL=$git_url" >> $GITHUB_ENV
          git_branch=$(git rev-parse --abbrev-ref HEAD)
          echo "GIT_BRANCH=$git_branch" >> $GITHUB_ENV
      - uses: webfactory/ssh-agent@v0.4.1
        with:
          ssh-private-key: ${{ secrets.SDK_REPO_SSH_KEY }}
      - uses: actions/setup-node@v2
        with:
          node-version: "12"
      - run: npm install
      - run: npm run build-dev

      # v2 works with 3 new actions (login, setup-buildx and setup-qemu)
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to Docker Registry
        uses: docker/login-action@v1
        with:
          registry: ${{ env.DOCKER_REGISTRY_HOST }}
          username: ${{ env.DOCKER_REGISTRY_USER }}
          password: ${{ env.DOCKER_REGISTRY_PASS }}
      - name: Build and push
        uses: docker/build-push-action@v2
        id: docker_build
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: |
            ${{ env.DOCKER_REGISTRY_HOST }}/${{ env.DOCKER_REGISTRY_PROJECT }}/${{ env.APP }}:latest
            ${{ env.DOCKER_REGISTRY_HOST }}/${{ env.DOCKER_REGISTRY_PROJECT }}/${{ env.APP }}:${{ env.GIT_COMMIT_SHORT }}
          build-args: |
            SDK_SSH_KEY=${{ env.SDK_SSH_KEY }}
            VCS_REF=${{ env.GIT_COMMIT_SHORT }}
            VCS_URL=${{ env.GIT_URL }}
            VCS_BRANCH=${{ env.GIT_BRANCH }}
      - name: Image digest
        run: echo ${{ steps.docker_build.outputs.digest }}

      - name: Save Configuration
        run: |
          printf "{ "image" : { "name" : "%s", "tag" : "%s"}, "action" : "%s"}" 
          "${{ env.DOCKER_REGISTRY_HOST }}/${{ env.DOCKER_REGISTRY_PROJECT }}/${{ env.APP }}" 
          "${{ env.GIT_COMMIT_SHORT }}" 
          "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" 
          > data.json && cat data.json

      - name: "Upload Build Data Artifact"
        uses: actions/upload-artifact@v2
        with:
          name: build-data
          path: ${{ env.PROJCT_BUILD_DATA }}
          retention-days: 5

Logs

Run docker/build-push-action@v2
  with:
    context: .
    file: ./build.Dockerfile
    push: true
    tags: ***/dev/opsdash:latest
  ***/dev/opsdash:4b1ee15
  
    build-args: SDK_SSH_KEY=***
  
  VCS_REF=4b1ee15
  VCS_URL=
  VCS_BRANCH=build-pipeline
  
    pull: false
    no-cache: false
    load: false
    github-token: ***
  env:
    APP: opsdash
    DOCKER_FILE: ./build.Dockerfile
    DOCKER_REGISTRY_PROJECT: dev
    DOCKER_REGISTRY_HOST: ***
    DOCKER_REGISTRY_PASS: ***
    DOCKER_REGISTRY_USER: ***
    SDK_SSH_KEY: ***
  
    PROJCT_BUILD_DATA: data.json
    GIT_COMMIT_SHORT: 4b1ee15
    GIT_URL: ...
    GIT_BRANCH: build-pipeline
📣 Buildx version: 0.4.2
🏃 Starting build...
/usr/bin/docker buildx build --build-arg SDK_SSH_KEY=*** --build-arg VCS_REF=4b1ee15 --build-arg VCS_URL=... --build-arg VCS_BRANCH=build-pipeline --tag ***/dev/opsdash:latest --tag ***/dev/opsdash:4b1ee15 --iidfile /tmp/docker-build-push-fwPjdv/iidfile --file ./build.Dockerfile --push .
time="2020-12-24T08:08:17Z" level=warning msg="invalid non-bool value for BUILDX_NO_DEFAULT_LOAD: "
#1 [internal] load build definition from build.Dockerfile
#1 transferring dockerfile: 0.0s
#1 transferring dockerfile: 2B 0.0s done
#1 DONE 0.0s
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /tmp/buildkit-mount967127233/build.Dockerfile: no such file or directory
Error: buildx call failed with: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /tmp/buildkit-mount967127233/build.Dockerfile: no such file or directory

I am new to Docker and i am trying to create an image from my application, i created Dockerfile in the same directory with package.json file with no extension, just Dockerfile

Now in Dockerfile:

FROM node:14.16.0
CMD ["/bin/bash"]

and i am trying to build the image with that command

docker build -t app .

But i got this constant error:

[+] Building 0.2s (2/2) FINISHED
 => [internal] load build definition from Dockerfile                                                           0.2s 
 => => transferring dockerfile: 2B                                                                             0.0s 
 => CANCELED [internal] load .dockerignore                                                                     0.0s 
 => => transferring context:                                                                                   0.0s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount457647683/Dockerfile: no such file or directory

My folder directory is like this:

   |- Dockerfile
   |- README.md
   |- src
   |- package.json
   |- public
   |- node-modules
   |-package-lock.json

My OS is : Windows 10 Pro

asked Mar 24, 2021 at 4:24

Saher Elgendy's user avatar

Saher ElgendySaher Elgendy

1,4194 gold badges14 silver badges26 bronze badges

1

Double check that you are in the right directory.
I was in downloads/app

When I downloaded the app from Docker as part of their tutorial, I extracted it and it ended up in downloads/app**/app**
Type dir in your terminal to see if you can see dockerfile or another folder called app.

answered Oct 16, 2021 at 11:57

tedtrux's user avatar

1

I encountered a different issue, so sharing as an FYI. On Windows, I created the docker file as DockerFile instead of Dockerfile. The capital F messed things up.

buddemat's user avatar

buddemat

3,89612 gold badges23 silver badges47 bronze badges

answered Jan 16, 2022 at 20:15

gallaleo's user avatar

gallaleogallaleo

1571 silver badge3 bronze badges

1

If you come here from a duplicate, notice also that Docker prevents you from accessing files outside the current directory tree. So, for example,

docker build -f ../Dockerfile .

will not be allowed. You have to copy the Dockerfile into the current directory, or perhaps run the build in the parent directory.

For what it’s worth, you also can’t use symlinks to files elsewhere in your file system from docker build for security reasons.

answered Apr 13, 2022 at 3:19

tripleee's user avatar

tripleeetripleee

170k31 gold badges261 silver badges305 bronze badges

Naming convention for Docker file is ‘Dockerfile’ not ‘DockerFile’, I got this error because of this.

answered Sep 22, 2022 at 15:27

krishna chaitanya yelleti's user avatar

1

In windows when the Dockerfile is in .txt format I got this error. changing it to type «file» fixed the issue.

answered Oct 17, 2021 at 14:07

SHAIK NAGULMEERA's user avatar

1

It’s a pretty generic error message but what caused it for me, was in my Dockerfile, I didn’t have a space specifying the initial command properly. Here’s how it should look like:

CMD ["command-name"]

Notice the space between «CMD» and «[«.

Instead, my mistake was that I typed CMD["command-name"] which resulted in the error you described.

answered Oct 27, 2022 at 13:19

Yann Borie's user avatar

Всем привет, помогите разобраться с Docker(ом) у меня есть следующий Dockerfile

FROM redis
COPY redis.conf C:/Projects/RedisFiles/redis.conf
CMD [ "redis-server", "C:\Projects\RedisFiles\redis.conf" ]

Который работает с образом Redis, но при запуске команды
docker build .
появляется ошибка

failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount878225771/Dockerfile: no such file or directory

Как можно ее исправить?


  • Вопрос задан

    более года назад

  • 1762 просмотра

Пригласить эксперта

как вариант, если вы работает на WIndows через wsl Linux, а имена файлов чувствительный к регистру, попробуйте переименовать Dockerfile на dockerfile

1. Убедится, что файл Dockerfile находится в той же директории, откуда запускается команда.
2. Убедится, что файл называется Dockerfile. С заглавной первой буквой и строчной «f» и без расширения (например, txt).
3. Если файл называется по-другому, то указать его название:
docker build . --file Dockerfile.base

Источник.


  • Показать ещё
    Загружается…

09 февр. 2023, в 10:11

1500 руб./в час

09 февр. 2023, в 09:28

5000 руб./за проект

09 февр. 2023, в 07:58

3500 руб./за проект

Минуточку внимания

Introduction

As exist in the title of this article, there is a specific error appear upon building a docker image. In this article, the focus of the content is to be able to solve that error. It appear upon executing the following command in order to build the docker image :

C:repositorydjangoprojectbuilder>docker-compose build
Building web
[+] Building 0.1s (2/2) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                   0.0s
 => => transferring dockerfile: 2B                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                      0.1s
 => => transferring context: 2B                                                                                                                                        0.0s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount498198349/Dockerfile: no such file or directory
ERROR: Service 'web' failed to build : Build fail

C:repositorydjangoprojectbuilder>

Solution

Basically, before solving the error message as exist in the above part. The error appear so that it ends in failure for building the docker image. The following is the actual directory structure of the ‘builder’ folder :

C:repositorydjangoprojectbuilder>tree /A /F
Folder PATH listing
Volume serial number is FC64-E91F
C:.
|   docker-compose.yml

C:repositorydjangoprojectbuilder>

After searching Google for a solution, actually the solution for solving the above problem is simple. It is because of the non-existence of the ‘dockerfile’ which is normally present as ‘DockerFile’. It is exist as part of the error message above which is ‘failed to read dockerfile’. In that case, in order to solve the problem, just provide the ‘DockerFile’. The following is the content of the ‘DockerFile’ with a simple content :

# pull image
FROM centos

# set work directory
WORKDIR /var/www

Running the command again once more to build the image is a success. It is after the existence of the ‘DockerFile’ as in the following command execution :

C:repositorydjangoprojectbuilder>docker-compose build
Building web
[+] Building 0.3s (6/6) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                   0.2s
 => => transferring dockerfile: 352B                                                                                                                                   0.1s
 => [internal] load .dockerignore                                                                                                                                      0.2s
 => => transferring context: 2B                                                                                                                                        0.1s
 => [internal] load metadata for docker.io/library/centos:latest                                                                                                       0.0s
 => [1/2] FROM docker.io/library/centos                                                                                                                                0.0s
 => CACHED [2/2] WORKDIR /var/www                                                                                                                                      0.0s
 => exporting to image                                                                                                                                                 0.0s
 => => exporting layers                                                                                                                                                0.0s
 => => writing image sha256:7c055c0a93f918fb6ad256163dc9c379ae13aee423ffaebaa251e174509636bb                                                                           0.0s
 => => naming to docker.io/library/builder_web                                                                                                                         0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

C:repositorydjangoprojectbuilder>

Last but not least, just execute the built image resulted from the execution of the previous command. Just run the following command to do it :

C:repositorydjangoprojectbuilder>docker run -it --name mycontainer -d bash builder_web
f25f99cd8d9583486db10ccc59fec999e7ca3367b26f1c8868de5b0e876b515b

C:repositorydjangoprojectbuilder>

After executing the above command to create a new running container, check it after. It is important to check if the container exist or not as follows :

C:repositorydjangoprojectbuilder>docker container list --all
CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS                       PORTS                    NAMES
f25f99cd8d95   bash       "docker-entrypoint.s…"   17 seconds ago   Exited (127) 8 seconds ago                            mycontainer
44fdcb5a7482   centos     "/bin/bash"              7 hours ago      Up 7 hours                   0.0.0.0:80->80/tcp       sinergi
8a52dcce139c   registry   "/entrypoint.sh /etc…"   8 days ago       Up 42 hours                  0.0.0.0:5000->5000/tcp   hub.local

C:repositorydjangoprojectbuilder>

Finally, the last command below is just a command which is trying to prove that the container above exist but it is not running anymore. Because according to the output above, it has already exited. The command for executing a process for an already running container exist as follows :

C:repositorydjangoprojectbuilder>docker exec -it mycontainer bash
Error response from daemon: Container f25f99cd8d9583486db10ccc59fec999e7ca3367b26f1c8868de5b0e876b515b is not running

C:repositorydjangoprojectbuilder>

Hello,

I am a beginner with Docker and I am trying to learn.

But when I build a new docker image this is what happens:

PS C:Usersmilan> docker build . -f Dockerfile -t test

[+] Building 0.1s (2/2) FINISHED

=> [internal] load build definition from Dockerfile 0.1s

=> => transferring dockerfile: 2B 0.0s

=> [internal] load .dockerignore 0.0s

=> => transferring context: 2B 0.0s

failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount202213367/Dockerfile: no such file or directory

My Dockfile path: C:/app/Dockerfile

My Dockerfile:

FROM debian:9
RUN apt-get update -yq 
&& apt-get install curl gnupg -yq 
&& curl -sL https://deb.nodesource.com/setup_10.x | bash 
&& apt-get install nodejs -yq 
&& apt-get clean -y
ADD . /app/
WORKDIR /app
RUN npm install
EXPOSE 2368
VOLUME /app/logs
CMD npm run start

My .dockerignore file:

node_modules
.git

Would you know what is causing this error ?

Thank you.

Internship at OpenGenus

Get this book -> Problems on Array: For Interviews and Competitive Programming

In this article, we have explored the reason behind the error «failed to solve with frontend dockerfile.v0» and presented multiple ways (5) to fix it. This error is related to Buildkit and LLB component of Docker.

Table of contents:

  1. The Error: failed to solve with frontend dockerfile.v0
  2. Fix 1: Disable Buildkit of Docker
  3. Fix 2: Ensure Dockerfile is named correctly
  4. Fix 3: Specify filename in docker-compose.yml
  5. Fix 4: Delete token seed
  6. Fix 5: Disable Buildkit from settings
  7. Concluding Note

Following error summarizes the case of this error:

Point Details on error
Error: failed to solve with frontend dockerfile.v0
Variants of the error:
  • failed to compute cache key: «/.env» not found: not found
  • error from sender: context canceled
  • rpc error: code = Unknown desc = failed to parse
  • and more.
Source of error: Modcache, Buildkit or LLB component in Docker
When error comes? While building a Docker file
Number of possible fixes 5

While building a Docker using the following command, you may encounter a specific error that will act as a blocker.

docker build . -t opengenus

Following is the error you may get depending on your environment:

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

OR

failed to solve with frontend dockerfile.v0: failed to build LLB:
error from sender: context canceled

This can be attributed to a known issue with the Modcache or Buildkit in Docker system. There can be other sources of this error and as we have presented multiple solutions.

  • LLB stands for Low Level Build and is a binary format that is used internally by Docker. It uses a graph data structure.
  • Frontend is the component in Docker that converts the defined Docker build format to LLB.
  • The error happens in this step.

Following components are the source of this error:

  • Buildkit
  • LLB
  • Frontend (error occurs in this step)

Fix 1: Disable Buildkit of Docker

Buildkit is a new utility in Docker that replaces the legacy builder. It has a feature to reuse dockerfiles for optimal performance and handle complex situations. It has been observed that the utility does not work well with all legacy docker files and hence, the error will come. The fix is to disable Buildkit using the following two environmental variables:

export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0

Following this, try building the Docker again and the error will be fixed:

docker build . -t opengenus

Depending on your system environment, if this fix does not work, move to the next fix. You need not revert back the changes in this fix.

Fix 2: Ensure Dockerfile is named correctly

Make sure that the docker file is named as «Dockerfile» exactly and not as other variants like «DockerFile», «dockerfile» and others.

The docker command fetches this file in a case-sensitive fashion and if it is wrongly named, the docker command is unable to find the setting file and hence, the error may come up.

Fix 3: Specify filename in docker-compose.yml

If the above fix does not work, we may try to specific the Docker file name in docker-compose.yml file to ensure that the Docker picks up the right file overcoming Modcache component.

By default, docker-compose.yml will look as follows:

version: "3"
...
    build:
      context: ../.
      dockerfile: .

It should be updated as:

version: "3"
...
    build:
      context: ../.
      dockerfile: Dockerfile

Notice the last line where the filename is specified.

Fix 4: Delete token seed

If you are using MacOS and you get this error:

failed to solve with frontend dockerfile.v0: failed to create LLB definition: 
rpc error: code = Unknown desc = failed to parse 
/Users/opengenus/.docker/.token_seed: unexpected end of JSON input

The simple fix is to delete the following 2 files in /Users/opengenus/.docker/ directory:

  • .token_seed
  • .token_seed.lock

This will start a fresh build ignoring the cached components from the previous failed Docker builds.

Fix 5: Disable Buildkit from settings

In Fix 1, we tried to disable Buildkit through environment variables. In some cases, when Docker is used in a Desktop system running Windows or MacOS, we need to disable it from the settings.

Disable buildkit in «Docker Engine» JSON config (in Docker on desktop system). The steps are as follows:

  • Open Docker Desktop applications
  • Go to Settings
  • Go to «Docker Engine»
  • Update the true value for buildkit to false in features section.
# Change this line
"features": { buildkit: true}
# to
"features": { buildkit: false}

This should finally fix the error and you can proceed forward building the Docker file.

Concluding Note

Docker is an important tool with several components which may not work well with legacy Docker files. Resolving such errors and proceeding to build Docker files is easy if you find the right fix as presented in this article at OpenGenus.

With this article at OpenGenus, you must have the complete idea of how to solve this Docker error successfully.

Содержание

  1. [SOLVED] failed to solve with frontend dockerfile.v0
  2. The Error: failed to solve with frontend dockerfile.v0
  3. Fix 1: Disable Buildkit of Docker
  4. Fix 2: Ensure Dockerfile is named correctly
  5. Fix 3: Specify filename in docker-compose.yml
  6. Fix 4: Delete token seed
  7. Fix 5: Disable Buildkit from settings
  8. Concluding Note
  9. Benjamin QoChuk, PhD
  10. Solution for Docker issue failed to solve: rpc error: code = unknown desc
  11. Docker Error Messages
  12. Problem
  13. Docker Setup
  14. Solution
  15. Conclusion
  16. WSL2: docker build — error getting credentials #11261
  17. Comments
  18. Actual behavior
  19. Expected behavior
  20. Information
  21. Steps to reproduce the behavior
  22. Working Quick-Fix
  23. Some guesses
  24. Cannot build from local image with buildctl (OCI Worker) #1142
  25. Comments

[SOLVED] failed to solve with frontend dockerfile.v0

In this article, we have explored the reason behind the error «failed to solve with frontend dockerfile.v0» and presented multiple ways (5) to fix it. This error is related to Buildkit and LLB component of Docker.

Table of contents:

  1. The Error: failed to solve with frontend dockerfile.v0
  2. Fix 1: Disable Buildkit of Docker
  3. Fix 2: Ensure Dockerfile is named correctly
  4. Fix 3: Specify filename in docker-compose.yml
  5. Fix 4: Delete token seed
  6. Fix 5: Disable Buildkit from settings
  7. Concluding Note

Following error summarizes the case of this error:

Point Details on error Error: failed to solve with frontend dockerfile.v0 Variants of the error:

  • failed to compute cache key: «/.env» not found: not found
  • error from sender: context canceled
  • rpc error: code = Unknown desc = failed to parse
  • and more.

Source of error: Modcache, Buildkit or LLB component in Docker When error comes? While building a Docker file Number of possible fixes 5

The Error: failed to solve with frontend dockerfile.v0

While building a Docker using the following command, you may encounter a specific error that will act as a blocker.

Following is the error you may get depending on your environment:

This can be attributed to a known issue with the Modcache or Buildkit in Docker system. There can be other sources of this error and as we have presented multiple solutions.

  • LLB stands for Low Level Build and is a binary format that is used internally by Docker. It uses a graph data structure.
  • Frontend is the component in Docker that converts the defined Docker build format to LLB.
  • The error happens in this step.

Following components are the source of this error:

  • Buildkit
  • LLB
  • Frontend (error occurs in this step)

Fix 1: Disable Buildkit of Docker

Buildkit is a new utility in Docker that replaces the legacy builder. It has a feature to reuse dockerfiles for optimal performance and handle complex situations. It has been observed that the utility does not work well with all legacy docker files and hence, the error will come. The fix is to disable Buildkit using the following two environmental variables:

Following this, try building the Docker again and the error will be fixed:

Depending on your system environment, if this fix does not work, move to the next fix. You need not revert back the changes in this fix.

Fix 2: Ensure Dockerfile is named correctly

Make sure that the docker file is named as «Dockerfile» exactly and not as other variants like «DockerFile», «dockerfile» and others.

The docker command fetches this file in a case-sensitive fashion and if it is wrongly named, the docker command is unable to find the setting file and hence, the error may come up.

Fix 3: Specify filename in docker-compose.yml

If the above fix does not work, we may try to specific the Docker file name in docker-compose.yml file to ensure that the Docker picks up the right file overcoming Modcache component.

By default, docker-compose.yml will look as follows:

It should be updated as:

Notice the last line where the filename is specified.

Fix 4: Delete token seed

If you are using MacOS and you get this error:

The simple fix is to delete the following 2 files in /Users/opengenus/.docker/ directory:

This will start a fresh build ignoring the cached components from the previous failed Docker builds.

Fix 5: Disable Buildkit from settings

In Fix 1, we tried to disable Buildkit through environment variables. In some cases, when Docker is used in a Desktop system running Windows or MacOS, we need to disable it from the settings.

Disable buildkit in «Docker Engine» JSON config (in Docker on desktop system). The steps are as follows:

  • Open Docker Desktop applications
  • Go to Settings
  • Go to «Docker Engine»
  • Update the true value for buildkit to false in features section.

This should finally fix the error and you can proceed forward building the Docker file.

Concluding Note

Docker is an important tool with several components which may not work well with legacy Docker files. Resolving such errors and proceeding to build Docker files is easy if you find the right fix as presented in this article at OpenGenus.

With this article at OpenGenus, you must have the complete idea of how to solve this Docker error successfully.

Benjamin QoChuk, PhD

Benjamin QoChuk is a Computer Science Researcher, Inventor and Author. His educational background include Bachelors at Vanderbilt University and PhD in Computer Science at Peking University.

Источник

Solution for Docker issue failed to solve: rpc error: code = unknown desc

This post presents a solution to an error I encountered recently with Docker when trying to bring up a docker container using docker-compose.

The solution in the post helped me fix the Docker issue failed to solve: rpc error: code = unknown desc = failed to solve with frontend dockerfile v0

Docker Error Messages

If you have been having the same problem as me, you might get one of the following error messages from Docker:

docker failed to solve rpc error code = unknown desc

docker failed to solve with frontend dockerfile.v0

failed to solve: rpc error: code = unknown desc = failed to solve with frontend dockerfile v0

Docker build error: failed to solve with the frontend dockerfile

Problem

The problem with Docker was happening when I was trying to bring up docker using a docker-compose file. I was using a command similar to this one:

> sudo -E docker-compose -f docker-compose.yml -f docker-compose.local.yml up —build

The error message I got was as follows:

I tried a few variations to bring up the docker containers

> sudo docker-compose -f docker-compose.local.yml up -d

I got similar error messages from docker:

I also tried to clear out existing docker containers and images from the cache. > sudo docker system prune -a -f This did not work when I tried to rebuild docker containers as above.

The consistent error from each of the commands I tried that failed seemed to be not finding a docker file.

Docker Setup

You can skip to the solution here, as this section helps check if docker is correctly installed.

The first step you can try is to make sure you can actually run a ‘hello world’ docker image successfully. You can do this by executing the following command:

> docker run hello-world

The output of this command should be as follows:

As suggested in the output of the docker hello world example, you can try a more advanced docker test, which would be to run the latest ubuntu image and execute command via the bash terminal in ubuntu.

> docker run -it ubuntu bash

The output should be as follow, and should give you terminal access as the root user.

Solution

The solution is to explicitly give the name of the docker file in the docker-compose.yml. Change how you specify the location of your dockerfile from dockerfile: . to dockerfile: Dockerfile

This is an sample of the docker-compose file which did not work on Ubuntu 20.04 or Windows10, it only seems to work on MacOS only. As you can see, the dockerfile location is specified as a ‘.’

The sample docker-compose file shown below is a working cross platform file, which works on MacOS, Ubuntu, Windows10.

As you can see, the line specifying the dockerfile has been changed from a dot ‘.’ to the explicit file name, in my case, it was ‘Dockerfile’.

This also works with lower and uppercase docker files as dockerfile: Dockerfile or dockerfile: dockerfile

Conclusion

The problem seemed to originate from the cross platform development and testing of the docker-compose script, between MacOS and Ubuntu / Window10 using version 3 of docker-compose. In the scenario of specifying the location of the dockerfile.

The original docker-compose file was built on MacOS, I was trying to use the same file but on Ubuntu 20.04. I believe this same problem can also occur if also trying to use docker-compose developed using MacOS on Windows10.

If you are using MacOS, then this docker-compose file will most likely run without any problems (if you do not have any other unrelated problems).

You can read more about how I have used docker in my other projects.

What can you do to improve your life as a programmer?

my article provides some ideas!

If this article helped you out, consider buying me a beer coffee?

Creating your first programming language is easier than you think,
. also looks great on your resume/cv.

Any comments? Send me a message on twitter @AyeshAlshukri or on Reddit /user/AyeshAlshukri/

Источник

WSL2: docker build — error getting credentials #11261

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID: A5DA81D0-A2FF-424C-BF0F-B77C182B756F/20210520130721

Actual behavior

On new installed system/device (non-English localized Windows, WSL2, Docker Desktop, no credentials in windows credential store), docker build . exits for a fairly simple Dockerfile (see: steps to reproduce) with the error:

Expected behavior

On new installed system/device (non-English localized Windows, WSL2, Docker Desktop, no credentials in windows credential store), docker build . for a fairly simple Dockerfile (see: steps to reproduce) just works as expected.

Information

Is it reproducible? Yes

Is the problem new? Yes

Did the problem appear with an update? No

Windows Version: 20H2 (Build 19042.508) — non-English localized

Docker Desktop Version: 3.3.3 (64133)

WSL2 or Hyper-V backend? WSL2

Are you running inside a virtualized Windows e.g. on a cloud server or a VM? No

Steps to reproduce the behavior

  1. Install a new copy / set you current copy of Windows 10 Version 20H2 (Build 19042.508) with language set to anything but English
  2. Install WSL2 following the manual at Microsoft Docs with latest Debian image
  3. Install Docker Desktop for Windows Version 3.3.3 (64133), enable WSL integration
  4. Ensure that there are non entries in windows credential manager
  5. Create a (temporary) directory for testing docker build (whether within WSL or Windows filesystem — does not make a difference)
  6. cd into the previously created (temporary) testing directory
  7. Create this fairly simple Dockerfile:

Working Quick-Fix

I found out that disabling the buildkit feature by configuring the Docker Engine via Docker Desktop solves this issue.

Nevertheless I wanted to report my struggle here, since I was just installing everything at current versions on a clean and new system and it does not work without custom configuration. Also I do not know the side-effects for disabling buildkit , so I am looking for a clean solution, i.e. bugfix, for this basic use-case issue.

Some guesses

This issue might be related to the WSL users Docker .config file.

But maybe I am wrong with this guess.

The text was updated successfully, but these errors were encountered:

I just found out that executing C:Program FilesDockerDockerresourcesbindocker-credential-desktop.exe list from within standard Windows command prompt gives the same error:

Credential Helper version: 0.6.3

By the way, editing

/.docker/config.json will not last. «credsStore»: «desktop.exe» gets added automatically on Docker restart.

I investigated a bit further and found something interesting.

First, the issue does not show on English-language systems or when there is any credential saved in windows credential store (It does not matter which one but there has to be one).

So this issue only shows on non-English systems with no credentials stored in the windows credential store.

And here is the explanation:

The currently most recent (released) Credential Helper (version 0.6.3) has been released on 16 Jul 2019.

Источник

Cannot build from local image with buildctl (OCI Worker) #1142

Description

Cannot build from a local image with buildctl which always tries to resolve to docker.io . This applies to a multi-stage setup or simply from a local image in a CI setup. The base image should not be expected to be pushed to any repository (either docker.io or even private). It is only available locally ( docker images ).

This works with docker build and even DOCKER_BUILDKIT=1 using image names (but not SHA ID in the last case). See also moby/moby#39769.

This looks similar to the problems with local cache described here: moby/moby#39003.

Steps to reproduce the issue:

  1. Demo project available here: https://github.com/virgile-hogman/docker-buildkit
  2. Run ./buildctl-build.sh from bash
  3. See logs, fails to resolve FROM docker.io/library/bk1:latest

Describe the results you received:

Describe the results you expected:

This should work as for docker build when using image names (with or without DOCKER_BUILDKIT=1 . Note with SHA-ID it does not work either in the last case as described in moby/moby#39769).

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version :

Output of docker info :

Additional environment details (AWS, VirtualBox, physical, etc.):

Connected to a private repository on a different host but this should not have effect here since it works with standard docker build .

The text was updated successfully, but these errors were encountered:

Buildkit with oci worker does not provide an image store. This has been discussed in the past but would mean we would need to add image management commands in the API. You can use containerd worker with the containerd image store(managed with ctr) or docker/buildx with docker image store.

@tonistiigi thanks for the answer, but coming just from the «docker world» i don’t know exactly how to use containerd from buildkit in practice, especially the fetching part.

In this example i have a Dockerfile depending on a first one built only locally. Let’s assume it is stored with containerd. But then it’s still buildkit that needs to load it, so how would it find it in that local store? Do you need to name the local image in a particular way?

But then it’s still buildkit that needs to load it, so how would it find it in that local store? Do you need to name the local image in a particular way?

The first build would export it with a name —output type=image,name=myname and then another build can refer to it by that name.

I tried this but the second build still fails for the same reason. I don’t still understand how the loaders work and how buildkit is going to find such image. I’m using the dockerized version of buildkit:

The first build produces an image that i can «somehow» see with buildctl du -v though i don’t see the image name. There are some IDs which are not prefixed by sha apart from the base image corresponding to the alpine image. What am i missing? I don’t know how to use ctr with this. The first image seems to be stored somewhere but i can’t tell where.

moby/buildkit:latest image is only configured for the oci worker. To run the containerd worker you need to have containerd running and start buildkitd with —oci-worker=false —containerd-worker=true

Is there any simple tutorial or documentation for setting up such a configuration? I have never used containerd and it sounds quite obscure to an end-user not familiar with terms like rund, containerd, workers or OCI, this all sounds like internal stuff for container developers which i’m not. The nice thing with Docker is its convenience and accessibility, it can be used out of the box from a simple apt installation. Here i don’t even know where to look.

I face the same problem, and tried to switch from oci to containerd worker but fails to boot the buildkit deamon.

The image tag for moby/buildkit is 8ce8d3df040f. I am running on Mac Docker desktop (2.1.03) with Engine version 19.03.2

Is that I must build the buildkitd myself if I want to test with the containerd worker? Thanks for your help.

I’m experiencing the same issue. Looking into the moby/buildkit image ( 8ce8d3df040f ) looks to me that there is no trace of containerd executables.

@tonistiigi since you suggested to start containerd before buildkitd —oci-worker=false —containerd-worker=true , can you please explain the necessary steps?
I went through the docs of docker/buildx , moby/buildkit and containerd/containerd with no luck.

I’m also freshly started with docker, but from the official documentation buildx is described as an improved version of build , but I’m a bit puzzled on why it can fail the very simple (and common I think) use case of creating an image starting from a base image already available locally under docker images .

As I wrote in #1142 (comment) moby/buildkit is made for oci worker. It does not come with containerd binaries. If you want to run containerd you can refer to their getting started guide https://github.com/containerd/containerd/blob/master/docs/getting-started.md#getting-started-with-containerd . If you have containerd running you can start buildkitd binary with configuration pointing to your containerd daemon. As containerd runs in host and requires clients to share the filesystem, normally you would run buildkitd in host as well in that case. There’s an old example of how to run them both in containers in #192 (comment) but that’s probably not what you want.

I’m also freshly started with docker, but from the official documentation buildx is described as an improved version of build, but I’m a bit puzzled on why it can fail the very simple (and common I think) use case of creating an image starting from a base image already available locally under docker images.

buildx doesn’t have anything to do with the question in here that is about buildctl. in buildx results are automatically get/put to docker images with docker driver, and with container driver —load loads the build results into docker. buildx never interacts with containerd daemon, nor does running a containerd daemon have any influence on the output of docker images .

Ok, I think I’m getting even more confused, maybe I’ll describe my use case more in detail to explain how I ended up here.
I’m running docker desktop on Mac OS.

  • I want to build a base image of a linux OS, for which I need to use the new buildkit experimental RUN —security=insecure in my Dockerfile
  • From the official docs, docker buildx build «extends the docker command with the full support of the features provided by Moby BuildKit builder» that looked to me like an easy entry point to use BuildKit
  • To be able to use RUN —security=insecure , I need to create a builder instance with the insecure entitlement enabled for the buildkitd daemon by:
    docker buildx create —name insecure-builder —buildkitd-flags ‘—allow-insecure-entitlement security.insecure’
    which creates and enables a builder using the docker-container driver
  • Now I can build my first image with: docker buildx build -t fvg/test:latest —load —allow security.insecure -f test.Dockerfile .
    here’s the sample test.Dockerfile:
  • The image is correctly visible (and usable) under docker image ls . Now I want to build a second image that is based on the first: docker buildx build -t fvg/test2:latest —load —allow security.insecure -f test2.Dockerfile .
    here’s the test2.Dockerfile:
  • The build fails looking to resolve docker.io/fvg/test:latest , failing to load the local image.

If I try the same using the default builder under docker buildx ls with driver docker it works without error, but then I cannot build using —allow security.insecure , which is not allowed apparently.

@gfrancesco If you want buildx to access docker images it needs to use docker driver. It is true that for the —security it was just added lately and can’t be enabled atm. in docker. The PR for that is in moby/moby#39144 and you need to wait for that fix in order to use these 2 features together. If you want to use —security today with the container driver you can use a registry or combine your requests into a multi-stage Dockerfile for the same behavior.

Thanks for helping, I’ll keep an eye on the PR and look into use a registry in the meantime 🙂

moby/moby#39144 has been merged in yet it looks like I got the same problem on circleci:

The dockerfile is a multi-stage dockerfile.

partial docker build script:

Output of the above is:

docker build script log:

Note that base image on circleci worked fine with buildkit enabled, so buildkit can work with circleci — it’s just fails in the situation above for some reason 🤔

Источник

edx

edx

164
Points

42
Posts

I’m trying to build docker image through command and getting error as:

failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount671411616/dockerfile: no such file or directory

Views:
20001

Total Answered:
1

Total Marked As Answer:
1


Posted On:
22-Jan-2021 00:18

Check docker file name and the file path.

 — Rahul Maurya  26-Jan-2021 01:15

Answers

edx

edx

164
Points

42
Posts

Thanks. Resolved error by putting correct docker name with proper case sensitive as: Dockerfile

Posted On:
31-Jan-2021 05:53

Понравилась статья? Поделить с друзьями:
  • Build error multiple tools write to the same file
  • Build error main o error 1
  • Build error dev cpp
  • Build error dev c 1073741819
  • Build error dev c 1073741674