Error while building worker image from example voting app - docker

I am getting below error while building worker image from example voting app. I am on Ubuntu 20.04.4 LTS.
Error -
root#ubuntu2004:/home/ubuntu/study/docker/example-voting-app/worker# docker build . -t worker
Sending build context to Docker daemon 10.24kB
Step 1/13 : FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:7.0 as build
failed to parse platform : “” is an invalid component of “”: platform specifier component must match"^[A-Za-z0-9_-]+$": invalid argument
Dockerfile -
https://github.com/dockersamples/example-voting-app/blob/main/worker/Dockerfile
I tried with below Dockerfile but its also giving me an error.
Dockerfile -
https://github.com/mmumshad/example-voting-app/blob/master/worker/Dockerfile
Error - file does exists in mentioned location
Step 3/10 : COPY src/Worker/Worker.csproj .
COPY failed: file not found in build context or excluded by .dockerignore: stat src/Worker/Worker.csproj: file does not exist
I have just started learning docker, Can someone please help.

Related

Manual build works, while build via docker-compose fails

Installed Versions
Application
Version
Docker
19.03.6, build 369ce74a3c
Docker Compose
v2.13.0
OS
Ubuntu 18.04.2 LTS
Docker definitions
docker-compose.yml
version: "2.3"
services:
builder:
build:
context: ./
dockerfile: Dockerfile
args:
- NODE_VERSION=${NODE_VERSION:-12.22.7}
image: redacted/node:${NODE_VERSION}
volumes:
- ./:/code
environment:
- BUILDKIT_PROGRESS=plain
.env
CLIENT=${CLIENT_PREFIX:-xx}
PUBLIC_URL=/${CLIENT}-dashboard
REACT_APP_NODEJS_SERVER=${CLIENT}-server
NODE_VERSION=12.22.7
Dockerfile
ARG NODE_VERSION="12.22.7"
FROM node:${NODE_VERSION}
VOLUME ["/code"]
WORKDIR /code
CMD "/code/build_ui.sh"
Issue description
Our project requires multiple versions of node & npm installed. To avoid compatibility issues, we are trying to use docker to stabilize the versions we need.
We use the below command to run the build for our application:
docker-compose run --rm builder
This works on some of our servers, but on some servers, I get either of the below errors:
failed to solve: failed to solve with frontend dockerfile.v0: failed to build llb: failed to load cache key: rpc error: code = unknown desc = error getting credentials - err: exit status 1, out: cannot autolaunch d-bus without x11 $display ubuntu.
Fixed this by following the guide here. However, given that I was trying to pull node and that is a public repo, I don't understand why docker was attempting a login. And why didn't this happen on all servers?
docker run Error response from daemon: No command specified
Fixed this temporarily by manually building the image using docker build command. But I really want the docker-compose to be able to build the image if the image doesn't exist.
I was expecting docker-compose to build the image on first run without issues and run the build_ui.sh on container execution.
When I get the above errors, if I manually build the docker image (and not wait for docker-compose to build it) using the below command, and then use the docker-compose run command it works.
docker build -t redacted/node:12.22.7 .
I am trying to figure out why docker-compose is not building the image correctly when the image doesn't exist.

Why does Docker checks any node versions if they already installed

I have built my custom frontend image
FROM node:16-alpine3.16
WORKDIR /usr/src/app
COPY . .
EXPOSE 4200
CMD ["npm", "run", "start"]
Than I run it with docker compose
docker compose up frontend-app --build
Image running and working as expected.
Than I run it with docker compose without --build flag
docker compose up frontend-app
Image running and working as expected.
But when I disable wi-fi (internet), and run previous command again with --build flag, it shows me an error:
=> ERROR [internal] load metadata for docker.io/library/node:14.15.5-alpine3.10 0.1s
------
> [internal] load metadata for docker.io/library/node:14.15.5-alpine3.10:
------
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head "https://registry-1.docker.io/v2/library/node/manifests/14.15.5-alpine3.10": Failed to lookup host: registry-1.docker.io
What is the point always check for the node updates if node already dowloaded, and even pulled separatly from docker image?
Next command shows that this image localy already exists:
docker pull node:14.15.5-alpine3.10
14.15.5-alpine3.10: Pulling from library/node
b038bcb63e9c: Already exists
2ad96160a6c4: Already exists
694a34677dcf: Already exists
253b9b23d1bc: Already exists
Digest: sha256:fd87531f9bf187273c77ad3ddd5067110ef983f998fc2ea1b9932950df78bd8c
Status: Downloaded newer image for node:14.15.5-alpine3.10
docker.io/library/node:14.15.5-alpine3.10
Using --build you are building again the image, why do you use it if you already have the image?
Use just docker-compose down & docker-compose-up

Quarkus jvm deploy remote docker fail

I deploy my quarkus app with dockerfile to remote docker in my windows computer, but it fails. How should I fix it?
I package my quarkus app successed.
I package it used maven jvm
This is my IDEA docker image setting
docker image setting
This is my dockerfile
FROM registry.access.redhat.com/ubi8/openjdk-17:1.11
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8080
USER 185
ENV AB_JOLOKIA_OFF=""
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
I get fail reason:
Error response from daemon: COPY failed: file not found in build context or excluded by .dockerignore: stat target/quarkus-app/lib/: file does not exist
Failed to deploy 'bigquarkus Dockerfile: src/main/docker/Dockerfile.jvm': Can't retrieve image ID from build stream
I find I mistake my build context folder, so the maven can not find the .dockerignore file. When I set my context folder to . , I can build and push my docker image.

Docker - Deamon Context is not pointing to local directory

I am on MAC and have docker desktop running. My dockerfile looks something like this -
FROM azul/zulu-openjdk:8
ARG buildNumber
COPY build/libs/my-jar${buildNumber}.jar my-jar.jar
EXPOSE 8080
CMD java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Dcom.sun.management.jmxremote -noverify ${JAVA_OPTS} -jar my-jar.jar
When I try to build an image docker build -t my-image:0.1 ., the COPY stage fails. What I mean is even though my current directory is /usr/me/projects/my-proj the COPY stage fails with an error message -
COPY failed: stat /var/lib/docker/tmp/docker-builder436046791/build/libs/my-jar.jar: no such file or directory
I would assume that the path I provided was for current dir. But docker is not building on my local machine, but building it remotely some place.
Output of docker context is -
docker context list
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock https://me-something.hcp.centralus.azmk8s.io:443 (default) swarm
Anyone know what I am doing wrong here?

Docker: failed to export image: failed to create image: failed to get layer

I got the following error:
failed to export image: failed to create image: failed to get layer
sha256:xxxxxxxxxxxxx: layer does not exist
Dockerfile:
FROM openjdk:8
COPY ./lib/ /usr/src/app/BOOT-INF/lib/
COPY ./lib/entities-1.0-SNAPSHOT.jar /usr/src/app/BOOT-INF/lib/entities-1.0-SNAPSHOT.jar
COPY ./app/ /usr/src/app/
WORKDIR /usr/src
CMD ["java", "-cp", "app/", "org.springframework.boot.loader.JarLauncher"]
Output:
Step 3/6 : COPY ./lib/entities-1.0-SNAPSHOT.jar /usr/src/entities-1.0-SNAPSHOT.jar
---> 3acb1f6c911a
Step 4/6 : COPY ./app.jar /usr/src/app.jar
failed to export image: failed to create image: failed to get layer sha256:33a94c44f7804ae3f57b9e72f94323c15cef7267be7eb95d90d2a1673c4b33b9: layer does not exist
Second run always helps - error disappears.
I'm building multiple different images (different jars), with different Dockerfiles in different directories. But content of Dockerfiles is the same.
I think this error appeared after I add:
COPY ./lib/entities-1.0-SNAPSHOT.jar /usr/src/app/BOOT-INF/lib/entities-1.0-SNAPSHOT.jar
I don't want to remove that row: app and entities is my libs. If I remove row - I'll got one layer with thirdparty libs (50mb) merged with entities (2mb).
This problem occurs with a specific sequence of COPY commands in a multistage build.
More precisely, the bug triggers when there is a COPY instruction producing null effect (for example if the content copied is already present in the destination, with 0 diff), followed immediately by another COPY instruction.
A workaround could be to add RUN true between COPY statements:
COPY ./lib/ /usr/src/app/BOOT-INF/lib/
RUN true
COPY ./lib/entities-1.0-SNAPSHOT.jar /usr/src/app/BOOT-INF/lib/entities-1.0-SNAPSHOT.jar
RUN true
COPY ./app/ /usr/src/app/
Another way that seems to work is to launch the build using BUILDKIT, like that:
DOCKER_BUILDKIT=1 docker build --tag app:test .
See: https://github.com/moby/moby/issues/37965
I received this error, but it didn't tell me anything. If you want it to output the actual error, use this:
docker-compose -f "docker-compose.yml" up --remove-orphans --force-recreate' <optional service: e.g. "nginx">
From:
ERROR: Service 'nginx' failed to build: failed to export image: failed to create image: failed to get layer sha256:63d3...: layer does not exist
To:
Creating project_nginx ... done
Attaching to project_nginx
nginx_1 | 2019/06/12 03:27:30 [emerg] 1#1: BIO_new_file("/etc/ssl/certs/dhparam.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/ssl/certs/dhparam.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
From there I could track down the actual issue. But, from the original error, you have no way of knowing what actually caused the failure.

Resources