Docker build. command is failing in my machine - docker

I am trying to build a docker and it is giving me below exception. Any idea what could be wrong
First Day with the docker so my question could be bit out of sync
docker build .
[+] Building 1.2s (5/5) FINISHED
=> [internal] load build definition from Docker file 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.5s
=> CACHED [1/2] FROM docker.io/library/alpine#sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0 0.0s
=> ERROR [2/2] RUN apk add --update redis 0.6s
------
> [2/2] RUN apk add --update redis:
#5 0.171 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/aarch64/APKINDEX.tar.gz
#5 0.364 281472913525832:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1913:
#5 0.365 ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.14/main: Permission denied
#5 0.365 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/main: No such file or directory
#5 0.366 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/aarch64/APKINDEX.tar.gz
#5 0.536 281472913525832:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1913:
#5 0.538 ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.14/community: Permission denied
#5 0.538 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/community: No such file or directory
#5 0.538 ERROR: unable to select packages:
#5 0.541 redis (no such package):
#5 0.541 required by: world[redis]
# Use an exisiting docker image as a base
From alpine
# Download and install a dependency
Run apk add --update redis
#Tell the image what to do when it starts as a container
CMD ["redis-server"]

Related

error An unexpected error occurred: "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz: getaddrinfo EAI_AGAIN registry.yarnpkg.com"

I was following the guide in Docker official guide, Guides->Get started->Part 2: Containerize an application.
git clone https://github.com/docker/getting-started.git
then I created a Dockerfile with content as below:
# syntax=docker/dockerfile:1
FROM node:18-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
EXPOSE 3000
I tried to build it, but an error happened
docker build -t getting-started .
Error information are as follows :
[+] Building 101.8s (12/12) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> resolve image config for docker.io/docker/dockerfile:1 13.7s
=> CACHED docker-image://docker.io/docker/dockerfile:1#sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> [internal] load .dockerignore 0.0s
=> [internal] load metadata for docker.io/library/node:18-alpine 11.9s
=> [1/4] FROM docker.io/library/node:18-alpine#sha256:b3f383c13d71066a4e2380d42f4563ac14ac76b3035a5bea4db84209e14665d5 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 2.49kB 0.0s
=> CACHED [2/4] WORKDIR /app 0.0s
=> CACHED [3/4] COPY . . 0.0s
=> ERROR [4/4] RUN yarn install --production 20.8s
------
> [4/4] RUN yarn install --production:
#10 0.456 yarn install v1.22.19
#10 0.516 [1/4] Resolving packages...
#10 0.689 [2/4] Fetching packages...
#10 5.792 error An unexpected error occurred: "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz: getaddrinfo EAI_AGAIN registry.yarnpkg.com".
#10 5.792 info If you think this is a bug, please open a bug report with the information provided in "/app/yarn-error.log".
#10 5.792 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
executor failed running [/bin/sh -c yarn install --production]: exit code: 1
Here is my enviroment :
WIN10 Family Edition 22H2
Docker Desktop 4.15.0 (93002)
I've tried to add command
yarn config set registry http://registry.npm.taobao.org/
in the Dockerfile, but this still happened. The modified Dockerfile is as below:
# syntax=docker/dockerfile:1
FROM node:18-alpine
WORKDIR /app
COPY . .
RUN yarn config set registry http://registry.npm.taobao.org/ && yarn install --production
CMD ["node", "src/index.js"]
EXPOSE 3000
Still didn't fix the error. And I can't find the log file /app/yarn-error.log

Docker Layer Cache Missing When It Should Hit

I'm building my docker images in GitLab CI and trying to cache the build so that if the app dependencies don't change, I don't need to re-build the entire image, but for some reason the Docker layer caching isn't working.
Dockerfile
FROM public.ecr.aws/lambda/python:3.9
RUN pip install poetry==1.3.2
WORKDIR /app
COPY ./pyproject.toml ./poetry.lock ./
RUN poetry config virtualenvs.create false && poetry install \
--no-interaction --no-ansi --without dev
ENV PYTHONPATH=/app
COPY . .
CMD ["app.handler"]
GitLab CI Log Output
$ docker build --cache-from "${CI_REGISTRY_IMAGE}:latest" -t $IMAGE_NAME .
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 321B done
#1 DONE 0.0s
#2 [internal] load .dockerignore
#2 transferring context: 145B done
#2 DONE 0.0s
#3 [internal] load metadata for public.ecr.aws/lambda/python:3.9
#3 DONE 0.5s
#4 importing cache manifest from registry.gitlab.com/foo/bar:latest
#4 DONE 0.0s
#5 [1/6] FROM public.ecr.aws/lambda/python:3.9#sha256:7e3bcdc955c2c3cab1101bbbfd55849c0f56a6b5a21a149d50df91deacad6aac
#5 resolve public.ecr.aws/lambda/python:3.9#sha256:7e3bcdc955c2c3cab1101bbbfd55849c0f56a6b5a21a149d50df91deacad6aac 0.0s done
#5 sha256:ebf75d2390460a5a59d7c52cc4d6e7f6840c610b399c069b0ccf531792d77c7d 3.00kB / 3.00kB done
#5 sha256:7e3bcdc955c2c3cab1101bbbfd55849c0f56a6b5a21a149d50df91deacad6aac 772B / 772B done
#5 sha256:e3d5decbab4ddca757c7de36637b50826165efddecfe8b7ef76db761f51b790d 1.58kB / 1.58kB done
#5 DONE 0.3s
#6 [internal] load build context
#6 transferring context: 1.16MB 0.2s done
#6 DONE 0.3s
...
The pipeline is successfully picking up on the latest build as you can see from the importing cache manifest from registry.gitlab.com/foo/bar:latest line. However, it doesn't seem to be caching any of the build steps.
Can anyone see a reason why the cache might be missing in this case?

Docker build fails in ubuntu 18.04 wsl2

I am trying to build docker image in my local machine , I am using docker desktop and ubuntu 18.04 distro wsl2.
It pulls the image successfully yet fails during the "RUN" phase.
I have tried many solutions provided yet no luck . Below is the error , if anybody has any clue please let me know. Been stuck with this since a while.
Docker Image:
FROM alpine:3.14
RUN apk add --no-cache mysql-client
ENTRYPOINT ["mysql"]
Error:
root#LAPTOP-BOSTG8L5:/home/abilash/alpine1# docker build .
[+] Building 14.4s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 118B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:3.14 3.3s
=> [1/2] FROM docker.io/library/alpine:3.14#sha256:4c869a63e1b7c0722fed1e402a6466610327c3b83bdddb94bd94fb71da7f638a 0.7s
=> => resolve docker.io/library/alpine:3.14#sha256:4c869a63e1b7c0722fed1e402a6466610327c3b83bdddb94bd94fb71da7f638a 0.0s
=> => sha256:dd53f409bf0bd55eac632f9e694fd190244fef5854a428bf3ae1e2b636577623 1.47kB / 1.47kB 0.0s
=> => sha256:c7ed990a2339ee598662849de4f56e2241399f5a32340c8c4a7bbd5378a12b5f 2.83MB / 2.83MB 0.6s
=> => sha256:4c869a63e1b7c0722fed1e402a6466610327c3b83bdddb94bd94fb71da7f638a 1.64kB / 1.64kB 0.0s
=> => sha256:92d13cc58a46e012300ef49924edc56de5642ada25c9a457dce4a6db59892650 528B / 528B 0.0s
=> => extracting sha256:c7ed990a2339ee598662849de4f56e2241399f5a32340c8c4a7bbd5378a12b5f 0.1s
=> ERROR [2/2] RUN apk add --no-cache mysql-client 10.3s
------
> [2/2] RUN apk add --no-cache mysql-client:
#4 0.293 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
#4 5.299 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
#4 5.299 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/main: temporary error (try again later)
#4 10.30 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.14/community: temporary error (try again later)
#4 10.30 ERROR: unable to select packages:
#4 10.30 mysql-client (no such package):
#4 10.30 required by: world[mysql-client]
------
executor failed running [/bin/sh -c apk add --no-cache mysql-client]: exit code: 1
Issue was with docker desktop I suppose. I uninstall docker desktop and did the docker install directly in wsl did few changes to the network-host and it worked fine.

docker build ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.14/community: temporary error (try again later)

hello guys i have wierd problem when i try to build docker image in ubuntu 22 vm
[+] Building 10.6s (5/14)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 864B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/kong/kong:2.7.0 0.0s
=> CACHED [ 1/12] FROM docker.io/kong/kong:2.7.0 0.0s
=> ERROR [ 2/12] RUN apk update && apk add git unzip luarocks 10.5s
------
> [ 2/12] RUN apk update && apk add git unzip luarocks:
#0 0.240 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
#0 5.245 ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.14/main: temporary error (try again later)
#0 5.283 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
#0 10.29 ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.14/community: temporary error (try again later)
#0 10.48 v3.14.3-58-g7fc21b9dfb [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]
#0 10.48 v3.14.3-57-g005638434d [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]
#0 10.48 2 errors; 14942 distinct packages available
------
failed to solve: executor failed running [/bin/sh -c apk update && apk add git unzip luarocks]: exit code: 2
docker version
Docker version 20.10.18, build b40c2f6
tried restarting docker engine but with no luck
added network=host fixed my problem
build:
context: ../kong2
network: host

`docker build` show output from `RUN` [duplicate]

This question already has answers here:
When using BuildKit with Docker, how do I see the output of RUN commands?
(3 answers)
Closed 1 year ago.
I have this Dockerfile, where I run a command with RUN, and I want to see its output when running docker build:
FROM alpine:3.14
COPY . .
RUN echo "here are some numbers: $(seq 10)"
When I run docker build ., it doesn't show the output of the above command:
[+] Building 2.8s (8/8) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 36B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:3.14 1.2s
=> [internal] load build context 0.1s
=> => transferring context: 188.24kB 0.1s
=> CACHED [1/3] FROM docker.io/library/alpine:3.14#sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0 0.0s
=> [2/3] COPY . . 0.4s
=> [3/3] RUN echo "here are some numbers: $(seq 10)" 0.2s
=> exporting to image 0.8s
=> => exporting layers 0.8s
=> => writing image sha256:7e0bf9ff04a7b4a3a53395d430ddd950500be9a53733cce22a1da1929cae1a0a 0.0s
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them.
How do I see what the output is?
Docker version:
$ docker --version
Docker version 20.10.6, build 370c289
Is that what are you looking for?
$ docker build --progress=plain .
Sending build context to Docker daemon 4.096kB
Step 1/3 : FROM alpine:3.14
3.14: Pulling from library/alpine
5843afab3874: Pull complete
Digest: sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0
Status: Downloaded newer image for alpine:3.14
---> d4ff818577bc
Step 2/3 : COPY . .
---> 106aa79185ae
Step 3/3 : RUN echo "here are some numbers: $(seq 10)"
---> Running in 30a81b6d5035
here are some numbers: 1
2
3
4
5
6
7
8
9
10
Removing intermediate container 30a81b6d5035
---> 3c059c9b6150
Successfully built 3c059c9b6150
$ docker --version
Docker version 19.03.8, build afacb8b
Docker is showing the output as it's generated, and then hiding it when the command is done. You can disable this interactive output by piping docker build to a file or pager. Make sure to pipe stderr as well as stdout. For example, in bash, the result of the command appears in item #7 here:
$ docker build . |& cat
#1 [internal] load build definition from Dockerfile
#1 sha256:0ce5eece4291db925ff5f4646c0f72c5c94a28a77431c2afd38ffa4c5a90ccab
#1 transferring dockerfile: 36B done
#1 DONE 0.0s
#2 [internal] load .dockerignore
#2 sha256:96c5d624b98a42c7926385cf683312588be6b5b47ce4512bbc5a0a59c4042367
#2 transferring context: 2B done
#2 DONE 0.0s
#3 [internal] load metadata for docker.io/library/alpine:3.14
#3 sha256:af035606328a1ce217c0e290353f888d2ee03ed437bef601e11d9cc421fbbb67
#3 DONE 0.9s
#4 [1/3] FROM docker.io/library/alpine:3.14#sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0
#4 sha256:2c66994e2bde1811eaa777244107d7b0d683d113e151d83a5f7aa09e37e1883f
#4 DONE 0.0s
#5 [internal] load build context
#5 sha256:c87370e17d42a78ca943cd74a0d2d983bc71dc609a92739af5013ed4373e31a6
#5 transferring context: 188.24kB 0.1s done
#5 DONE 0.1s
#4 [1/3] FROM docker.io/library/alpine:3.14#sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0
#4 sha256:2c66994e2bde1811eaa777244107d7b0d683d113e151d83a5f7aa09e37e1883f
#4 CACHED
#6 [2/3] COPY . .
#6 sha256:200618f800c74119b8db3b01ff18105a07477dcfae41f0528189443421f6ba31
#6 DONE 0.4s
#7 [3/3] RUN echo "here are some numbers: $(seq 10)"
#7 sha256:c094a42d846e25e5586053168f7231e17248fc7f09c75de1199642ad83688952
#7 0.241 here are some numbers: 1
#7 0.241 2
#7 0.241 3
#7 0.241 4
#7 0.241 5
#7 0.241 6
#7 0.241 7
#7 0.241 8
#7 0.241 9
#7 0.241 10
#7 DONE 0.3s
#8 exporting to image
#8 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#8 exporting layers
#8 exporting layers 0.8s done
#8 writing image sha256:7b4e8d44804bba048cf5aa47c58cd57ab701400143177fb63887ef51edc1a23b done
#8 DONE 0.8s
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

Resources