I am trying to create and image. But when I run docker build
. I keep getting the error:
Step 6/7 : RUN zypper update && zypper upgrade -y && zypper install -y git
---> Running in 81e84f3be4f0
/bin/sh: zypper: not found
The command '/bin/sh -c zypper update && zypper upgrade -y && zypper install -y git' returned a non-zero code: 127
First I was getting something similar with git
not being found. So after a bit of Googling, i found out that I probably need to install git
in the docker file.
So I added something like:
FROM maven:3.8.4 AS maven
FROM eclipse-temurin:11-jdk-alpine
RUN mkdir -p $HOME/images/lib/ && cd $HOME/images/lib/
RUN zypper update && zypper upgrade -y && zypper install -y git
#RUN apt-get update && apt-get upgrade -y && apt-get install -y git
RUN git clone MY_GIT_URL
But it errors out on the second line.
My Docker info is :
Client:
Context: default
Debug Mode: false
Server:
Containers: 9
Running: 0
Paused: 0
Stopped: 9
Images: 8
Server Version: 20.10.17-ce
Storage Driver: btrfs
Build Version: Btrfs v4.15
Library Version: 102
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux oci runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version: v1.1.4-0-ga916309fff0f
init version:
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.14.21-150400.24.33-default
Operating System: openSUSE Leap 15.4
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 9.714GiB
Name: localhost.localdomain
ID: U76D:CEPC:3L3J:ZTTL:C5UQ:TOEZ:DLXA:5NQQ:HOQ7:SHRC:KXBZ:HLJE
Docker Root Dir: /var/lib/docker
Debug Mode: false
Username: MY_USERNAME
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
CodePudding user response:
The container image eclipse-temurin:11-jdk-alpine
is based on Alpine Linux, not Suse. Thus, to install operating system packages, use apk
instead of zypper
. For example:
RUN apk update && apk add git