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
Related
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.
I have a docker-compose.yml and Dockerfile in the same folder. When running docker compose build this should result in one image and one container, but somehow I'm left with two images and two containers. The same docker-compose.yml and Dockerfile on my desktop however results in one image. What is happening here?
docker-compose.yml
version: '3.3'
services:
nginx-proxy:
build: .
restart: always
ports:
- '80:80'
- '443:443'
volumes:
- /etc/nginx/certs/domain.nl.crt:/etc/letsencrypt/live/domain.nl/cert.pem:ro
- /etc/nginx/certs/domain.nl.key:/etc/letsencrypt/live/domain.nl/privkey.pem:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
Dockerfile:
FROM nginxproxy/nginx-proxy
EXPOSE 80
EXPOSE 443
The output of docker compose build looks completely different on the server and on my desktop too.
Running docker compose build Linux server:
Sending build context to Docker daemon 404B
Step 1/3 : FROM nginxproxy/nginx-proxy
latest: Pulling from nginxproxy/nginx-proxy
f7a1c6dad281: Pull complete
4d3e1d15534c: Pull complete
9ebb164bd1d8: Pull complete
59baa8b00c3c: Pull complete
a41ae70ab6b4: Pull complete
e3908122b958: Pull complete
3016ffcb703f: Pull complete
d0b58d19b229: Pull complete
e75e1b46ae51: Pull complete
a1b8f07fa83d: Pull complete
b1ff9eda0cc4: Pull complete
d334f8d44841: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:5e0be3b1bb035301c5bb4edbe0dee5bc0f133d26866e3165f1912acb126e15d4
Status: Downloaded newer image for nginxproxy/nginx-proxy:latest
---> 65d9e0769695
Step 2/3 : EXPOSE 80
---> Running in 4bdc00f75332
---> 0ca795ce85fb
Step 3/3 : EXPOSE 443
---> Running in 3530eba2d3cf
---> 9440ccab1790
Successfully built 9440ccab1790
Successfully tagged nginx-proxy_nginx-proxy:latest
Result:
docker image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 0ca795ce85fb 46 minutes ago 156MB
nginx-proxy_nginx-proxy latest 9440ccab1790 46 minutes ago 156MB
nginxproxy/nginx-proxy latest 65d9e0769695 4 days ago 156MB
docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3530eba2d3cf 0ca795ce85fb "/app/docker-entrypo…" 25 seconds ago Created affectionate_vaughan
4bdc00f75332 65d9e0769695 "/app/docker-entrypo…" 25 seconds ago Created fervent_varahamihira
Running docker compose build Desktop:
[+] Building 2.4s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 31B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/nginxproxy/nginx-proxy:latest 2.1s
=> CACHED [1/1] FROM docker.io/nginxproxy/nginx-proxy#sha256:5e0be3b1bb035301c5bb4edbe0dee5bc0f133d26866e3165f1912acb126e15d4 0.0s
=> exporting to image 0.1s
=> => exporting layers 0.0s
=> => writing image sha256:f66ed6ec69a319ce3a15b1f1948720bdd8174d13299513cc162a812616874793 0.0s
=> => naming to docker.io/library/nginx-proxy_nginx-proxy
Result:
docker image ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx-proxy_nginx-proxy latest f66ed6ec69a3 4 days ago 156MB
docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
You're looking at two different build tools. The classic docker build performs each step using a container that gets committed into an dangling image. For some of those changes, the container isn't even run, it's just created. These are visible in the container and image listings. Deleting them may delete your build cache which will force a rebuild of the entire image, and while they report the size of all their layers, those layers are shared with the final created image, so deleting the dangling images often won't save much space (maybe a few kb for some json metadata). Because of that, people would leave them around.
The other build is using buildkit, which runs directly on containerd and runc, so you don't see the build artifacts in the docker container and image list. This is the preferred builder and enabled by default on newer versions of docker.
Windows 10, DockerDesktop v3.5.2, Docker v20.10.7
Whenever my computer is disconnected from the Internet
the command docker build -t my_image . produces output like the following.
Dockerfile contains line FROM some_public_image:123
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 187B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> ERROR [internal] load metadata for docker.io/library/some_public_image:123 0.0s
------
> [internal] load metadata for docker.io/library/some_public_image:123:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition:
failed to do request: Head https://registry-1.docker.io/v2/library/some_public_image/manifests/123:
dial tcp: lookup registry-1.docker.io on 192.168.65.5:53: no such host
Sometimes it causes build failure: not sure, but I guess when there were no network availability between the Docker daemon start and execution of docker build.
I suppose it tries to sync the pulled image with the repo version (i.e. check the image integrity), but would like to control this network activity and turn this "load metadata" off (saying I'm sure that all pulled images are fine) even when the connection is stable.
How to disable loading metadata while executing docker build command?
I have this problem too, and via Google I found other people asking about it with no good solution.
My workaround:
When I'm still on a good Internet connection I docker pull some_public_image:123.
docker tag some_public_image:123 this_is_stupid_but_i_retagged_some_public_image.
In my Dockerfile I use FROM this_is_stupid_but_i_retagged_some_public_image.
I wouldn't merge this hack to main but it let me be productive on a long trip.
I am learning the docker , but don't know where i am going wrong.
Running the following command for the creating the Image from the Dockerfile:
Command: I am inside the the terminal where project is located and running below command:
docker build -f Dockerfile -t spring-boot-docker-ex .
Error Message:
time="2020-02-02T11:23:46+05:30" level=error msg="failed to dial gRPC: unable to upgrade to h2c, received 500"
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpuse
tmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=rveuxbqxdbzktl94h1jxp2s26&shmsize=0&t=docker_test&target=&
ulimits=null&version=1: context canceled
DockerFile:
FROM openjdk:latest
ADD target/dockerlearn-0.0.1-SNAPSHOT.jar dockerlearn.jar
ENTRYPOINT ["java","-jar","dockerlearn.jar"]
EXPOSE 8080
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.