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.
Related
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
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
This question already has an answer here:
Build args are not resolved
(1 answer)
Closed 4 months ago.
I have a docker file that as follows:
ARG ALPINE_VERSION=3.16.2
ARG GLAB_VERSION="1.22.0"
ARG JQ_VERSION="1.6"
FROM alpine:$ALPINE_VERSION
RUN apk add --no-cache "glab~=${GLAB_VERSION}" "jq~=${JQ_VERSION}"
ENTRYPOINT [ "glab" ]
When I try to build the image, I get an error because it is unable to resolve the version of glab:
docker build -t gitlab/glab:latest .
[+] Building 6.6s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 258B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:3.16.2 2.0s
=> CACHED [1/2] FROM docker.io/library/alpine:3.16.2#sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad 0.0s
=> ERROR [2/2] RUN apk add --no-cache "glab~=${GLAB_VERSION}" "jq~=${JQ_VERSION}" 4.4s
------
> [2/2] RUN apk add --no-cache "glab~=${GLAB_VERSION}" "jq~=${JQ_VERSION}":
#5 1.009 fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
#5 1.880 fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
#5 4.227 ERROR: 'glab~=' is not a valid world dependency, format is name(#tag)([<>~=]version)
------
executor failed running [/bin/sh -c apk add --no-cache "glab~=${GLAB_VERSION}" "jq~=${JQ_VERSION}"]: exit code: 99
If I update the Dockerfile to use hardcoded values:
RUN apk add --no-cache "glab~=1.22.0" "jq~=1.6"
it works:
docker build -t gitlab/glab:latest .
[+] Building 17.5s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 239B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/alpine:3.16.2 0.6s
=> CACHED [1/2] FROM docker.io/library/alpine:3.16.2#sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad 0.0s
=> [2/2] RUN apk add --no-cache "glab~=1.22.0" "jq~=1.6" 16.6s
=> exporting to image 0.2s
=> => exporting layers 0.2s
=> => writing image sha256:46bccd18a999a696ef9e80fb75983a6b5655a774b88b1412b55707cb152823e5 0.0s
=> => naming to docker.io/gitlab/glab:latest 0.0s
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Is it possible to use ARG to set the versions somehow?
The issue was becuase I was specifying the GLAB_VERSION and JQ_VERSION before the FROM ... instruction.
Updating the Dockerfile as follows works:
ARG ALPINE_VERSION=3.16.2
FROM alpine:$ALPINE_VERSION
ARG GLAB_VERSION=1.22.0
ARG JQ_VERSION="1.6"
RUN apk add --no-cache "glab~=${GLAB_VERSION}" "jq~=${JQ_VERSION}"
ENTRYPOINT [ "glab" ]
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"]
I'm trying to build an image from CentOS 6.9. Using this Dockerfile:
FROM centos:6.9
RUN ls
But it keeps failing with exit code 139 with the following output:
$ docker build -t centos-6.9 .
[+] Building 1.1s (7/7) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 72B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/centos:6.9 0.6s
=> [internal] load build context 0.1s
=> => transferring context: 72B 0.0s
=> CACHED [1/3] FROM docker.io/library/centos:6.9#sha256:6fff0a9edc920968351eb357c5b84016000fec6956e6d745f695e5a34f18ecd2 0.0s
=> [2/3] COPY . . 0.0s
=> ERROR [3/3] RUN ls 0.3s
------
> [3/3] RUN ls:
------
executor failed running [/bin/sh -c ls]: exit code: 139
I'm running:
Windows 10 Enterprise Version 2004
Docker Desktop 3.0.0
This appears to be an issue with WSL 2 with older base images, not docker or the image itself.
Create %userprofile%\.wslconfig file.
Add the following:
[wsl2]
kernelCommandLine = vsyscall=emulate
Restart WSL. wsl --shutdown
Restart Docker Desktop.
References:
https://github.com/microsoft/WSL/issues/4694#issuecomment-556095344
https://github.com/docker/for-win/issues/7284#issuecomment-646910923
https://github.com/microsoft/WSL/issues/4694#issuecomment-558335829