Unable to install Git in Dockerfile

I am trying to run my Dockerfile but somehow I am unable to install Git. The problem is that installing it via “zypper” causes an error.

My Dockerfile looks like this:

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 URL

And when I run it I get the error:

Step 6/7 : RUN zypper update && zypper upgrade -y && zypper install -y git
—> Running in 02b2f3dff125
/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

I am using OpenSuse Linux VM to do this. LEAP 15.4.

My Docker version is:

Client:
Version: 20.10.17-ce
API version: 1.41
Go version: go1.17.13
Git commit: a89b84221c85
Built: Wed Jun 29 12:00:00 2022
OS/Arch: linux/amd64
Context: default
Experimental: true

And Docker info is:

Client:
Context: default
Debug Mode: false

Server:
Containers: 11
Running: 0
Paused: 0
Stopped: 11
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: oci runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
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

Any help would be appreciated.

What is the base image? Have you installed zypper in the image before using it? The error message says zypper is not found.

PS.: Please, use code blocks (</> button) for terminal outputs and codes instead of quotes next time, so we can read and understand the question better.

The package manager you need to use depends on the os of the base image, not on the os of the host.

In order to use zypper as package manager, your Dockerfile must use a base image that actually provides it, like opensuse/leap:15 or opensuse/tumbleweed:latest.

1 Like

Yes, I found this out the hard way. I was assuming since I was on OpenSuse, using zypper command would be the way to go. apk get and apk update does work.

A post was split to a new topic: Proxy settings for the Docker daemon