Unable to start mosquitto on raspberry pi buster - mosquitto

Was trying to install npm and got message "ERROR: npm is known not to run on Node.js v11.4.0"
So unsinstalled nodejs and then mosquitto got stucked.
I can not start it .
pi#raspberrypi:/etc/mosquitto $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi#raspberrypi:~ $ sudo systemctl start mosquitto.service
Job for mosquitto.service failed because a fatal signal was delivered to the control process.
See "systemctl status mosquitto.service" and "journalctl -xe" for details.
if I run
pi#raspberrypi:~ $ systemctl status mosquitto.service
● mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
Active: failed (Result: signal) since Sun 2022-08-21 15:29:29 -03; 23s ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 820 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 821 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 822 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
Process: 823 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS)
Process: 824 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=killed, signal=ILL)
Main PID: 824 (code=killed, signal=ILL)
if I go to the mosquitto folder
pi#raspberrypi:/etc/mosquitto $ ls -l
total 16
drwxr-xr-x 2 root root 4096 Aug 19 14:20 ca_certificates
drwxr-xr-x 2 root root 4096 Aug 19 14:20 certs
drwxr-xr-x 2 root root 4096 Aug 19 14:20 conf.d
-rw-r--r-- 1 root root 385 Aug 20 21:31 mosquitto.conf
And this is my mosquitto.conf file
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.gz
pid_file /run/mosquitto/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
listener 1883
allow_anonymous true
I have manually added ,listener and allow, to see if that would make any difference. But same result<
If I run, I get illegal instruction. Do not understand why...
pi#raspberrypi:~ $ sudo /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Illegal instruction
Also can not get version since I get illegal instruction....
pi#raspberrypi:/etc/mosquitto $ mosquitto -v
Illegal instruction
pi#raspberrypi:/etc/mosquitto $ mosquitto -h
Illegal instruction
pi#raspberrypi:/etc/mosquitto $ file 'which mosquitto'
which mosquitto: cannot open `which mosquitto' (No such file or directory)
pi#raspberrypi:/etc/mosquitto $ uname -a
Linux raspberrypi 4.19.75+ #1270 Tue Sep 24 18:38:54 BST 2019 armv6l GNU/Linux
pi#raspberrypi:~ $ dpkg -s mosquitto
Package: mosquitto
Status: install ok half-configured
Priority: optional
Section: net
Installed-Size: 550
Maintainer: Roger A. Light <roger#atchoo.org>
Architecture: armhf
Multi-Arch: foreign
Version: 2.0.12-0mosquitto1~buster1
Config-Version: 1.6.10-0mosquitto1~buster1
Depends: adduser (>= 3.10), lsb-base (>= 4.1+Debian3), libc6 (>= 2.28), libcjson 1 (>= 1.7.5), libmosquitto1 (>= 1.6), libssl1.1 (>= 1.1.1), libsystemd0, libwebs ockets18 (>= 4.2.1), libwrap0 (>= 7.6-4~)
Suggests: apparmor
Conffiles:
/etc/init.d/mosquitto ee3001555cef9450c46fb2148c654cd1
/etc/logrotate.d/mosquitto f74e922f3bf6b513f76d5e47fabfb322
/etc/mosquitto/ca_certificates/README c1c6ae67f2def06c6a483be09b49d4de
/etc/mosquitto/certs/README 4d8a70d4cefab07d4dabc5be1f786c1f
/etc/mosquitto/conf.d/README b4ac621550824082a735732bfb42b51d
/etc/mosquitto/mosquitto.conf 6b48f97e52925e8cad9f32f991ef100d
Description: MQTT version 3.1/3.1.1/5.0 compatible message broker
This is a message broker that supports version 5.0 and 3.1.1 of the MQTT
protocol.
.
MQTT provides a method of carrying out messaging using a publish/subscribe model. It is lightweight, both in terms of bandwidth usage and ease of implementation.
pi#raspberrypi:~ $ ls /etc/apt
apt.conf.d listchanges.conf sources.list trusted.gpg trusted.gpg.d
auth.conf.d preferences.d sources.list.d trusted.gpg~
pi#raspberrypi:~ $ ls /etc/apt/sources.list.d
raspi.list
pi#raspberrypi:~ $ cd /etc/apt/sources.list.d
pi#raspberrypi:/etc/apt/sources.list.d $ ls -l
total 4
-rw-r--r-- 1 root root 284 Aug 19 10:55 raspi.list
Inside the file I have
#deb [trusted=yes] http://archive.raspberrypi.org/debian/ buster main
deb http://mirror.ufam.edu.br/raspbian/raspbian/ buster main contrib non- free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ buster main
Any idea how to bring back to life mosquitto?

OK,
I have reproduced this, you installed from the mosquitto ppa which provides both mosquitto and a newer copy of libwebsocket.
The SIGILL is coming from the libwebsocket library that appears to have been built targeting ARMv7 not ARMv6 (which is what the Pi Zero [W]) is using.
I have raised this with the mosquitto maintainer, with any luck it will fixed soon and upgrading will fix the problem.

Found similar problem here https://forums.raspberrypi.com/viewtopic.php?t=334388
fixed with these commands
apt remove mosquitto libwebsockets18
apt install mosquitto libwebsockets18=4.2.1-0mosquitto1~buster1

Related

Java Docker build slave finds java 8 even though it is not installed

Background
I have a Jenkins server on Ubuntu 18.04 running Java version 11, checked by visiting /manage/systemInfo
java.specification.version 11
I have implemented docker build slaves based on Ubuntu 22.04 where I have specified that the java version should be 11:
# install java for Jenkins
RUN apt-get install -qy openjdk-11-jdk
I was wondering that all the build nodes stood as offline, and reading the log saw this:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
This question references List of Java class file format major version numbers? the Class versions:
52 is java 8
55 is java 11
and sure enough, a little further back in the log:
[11/14/22 18:35:38] [SSH] Checking java version of java
[11/14/22 18:35:38] [SSH] java -version returned 1.8.0_312.
so I went hunting for the culprit:
Attempts to find the culprit
sudo docker container exec 20e1bfe2b182 ls -l /usr/bin/java returned
/usr/bin/java -> /etc/alternatives/java
sudo docker container exec 20e1bfe2b182 ls -l /etc/alternatives/java returned
/etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java
and even injected RUN java -version into my Dockerfile before the line installing opendjk (which indicated no java was installed...)
On the host I have run apt list --installed |grep jdk
openjdk-11-jdk/bionic-updates,bionic-security,now 11.0.17+8-1ubuntu2~18.04 amd64 [installed]
openjdk-11-jdk-headless/bionic-updates,bionic-security,now 11.0.17+8-1ubuntu2~18.04 amd64 [installed]
openjdk-11-jre/bionic-updates,bionic-security,now 11.0.17+8-1ubuntu2~18.04 amd64 [installed]
openjdk-11-jre-headless/bionic-updates,bionic-security,now 11.0.17+8-1ubuntu2~18.04 amd64 [installed,automatic]
... the same command on the docker image gave similar results...
find -name java* 2>/dev/null run from / did not give anything useful either
which java output
HOST:
$ which java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Nov 24 2018 /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 43 Jan 25 2022 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java
docker
$ sudo docker compose run man which java
/usr/bin/java
$ sudo docker compose run man ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Nov 14 20:28 /usr/bin/java -> /etc/alternatives/java
$ sudo docker compose run man ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 43 Nov 14 20:28 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java
echo $PATH output
HOST
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
docker
$ sudo docker compose run man echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Potential workaround
Adding this to my Dockerfile seems to almost solve the issue:
RUN ln -s /usr/lib/jvm/java-11-openjdk-amd64/ /home/jenkins/jdk
RUN chown jenkins:jenkins /home/jenkins/jdk
Question
... so where does the JDK version 8 come from?

Permission denied inside Docker container on shared directory

I'm new to Docker so I might not have some of the terminology correct. Inside the container I'm getting a permission denied error on a directory shared with the host. They appear to have matching uid:gid and the permissions host side are 777. The container is not for running in the background.
I'm using the container to run a big series of untrusted programs one at a time each needing the same initial conditions. So I don't think it's feasible to copy stuff into the docker image at build time. I felt the optimal thing to do is copy the programs one at a time to a temp directory on the host and then share that directory with the fresh container for each run. I also need to collect the output from the container-run programs and keep them on the host so I can see how each program's output differs from the others.
I have looked at the following questions/answers:
Docker: Copying files from Docker container to host
How to fix docker: Got permission denied issue - successfully used to make docker run as someone other than root
How do I add a user when I'm using Alpine as a base image? and Setting up a new user - used to create the user and group
I am:
running docker as an ordinary user uid 1000, gid 1000, also belonging to the group docker
setting permissions on the shared directory host side to be 777 with uid:gid as 1000:1000 which is the same as the user
setting the uid and gid inside the container to match uid and gid from the host
using the Dockerfile to create a uid and gid each of 1000
I read here that If the first argument begins with a / or ~/, you’re creating a bindmount. Remove that, and you’re naming the volume. So I tried both. The bindmount version seems to have the correct uid:gid but is permission denied, the volume version comes out as root:root.
As a newbie it's hard to know what information to share so here's everything I think might be useful:
Docker command attempt 1
[osboxes#osboxes tmp]$ pwd
/var/tmp
osboxes#osboxes tmp]$ whoami
osboxes
[osboxes#osboxes tmp]$ grep osboxes /etc/passwd
osboxes:x:1000:1000:osboxes.org:/home/osboxes:/bin/bash
[osboxes#osboxes tmp]$ groups
osboxes wheel vboxsf docker
[osboxes#osboxes tmp]$ grep osboxes /etc/group
wheel:x:10:osboxes
osboxes:x:1000:osboxes
vboxsf:x:981:osboxes
docker:x:1001:osboxes
[osboxes#osboxes tmp]$ ls -al
total 2
drwxrwxrwt. 11 root root 4096 Dec 31 12:13 .
drwxr-xr-x. 21 root root 4096 Jul 5 05:00 ..
drwxr-xr-x. 2 abrt abrt 6 Jul 5 05:00 abrt
drwxrwxrwx. 2 osboxes osboxes 6 Dec 31 12:13 host
continues...
[osboxes#osboxes tmp]$ docker run --rm -v /var/tmp/host:/var/tmp/container:rw \
--user appuser:appgroup --workdir /var/tmp/container \
-it alpine_bash_jdk11 /bin/bash
bash-5.0$ pwd
/var/tmp/container
bash-5.0$ ls -al
ls: can't open '.': Permission denied
total 0
bash-5.0$ ls -al ..
total 0
drwxrwxrwt 1 root root 23 Dec 31 12:51 .
drwxr-xr-x 1 root root 17 Dec 16 10:31 ..
drwxrwxrwx 2 appuser appgroup 6 Dec 31 12:13 container
bash-5.0$ whoami
appuser
bash-5.0$ groups
appgroup
bash-5.0$ grep appuser /etc/passwd
appuser:x:1000:1000:Linux User,,,:/home/appuser:/sbin/nologin
bash-5.0$ grep appuser /etc/group
appgroup:x:1000:appuser
Docker command attempt 2
everything as before except
for removing the qualified path to the host's
/var/tmp/host directory
docker run --rm -v host:/var/tmp/container:rw \
--user appuser:appgroup --workdir /var/tmp/container \
-it alpine_bash_jdk11 /bin/bash
bash-5.0$ pwd
/var/tmp/container
bash-5.0$ ls -al
total 0
drwxr-xr-x 2 root root 6 Dec 31 12:13 .
drwxrwxrwt 1 root root 23 Dec 31 13:03 ..
bash-5.0$ ls -al ..
total 0
drwxrwxrwt 1 root root 23 Dec 31 13:03 .
drwxr-xr-x 1 root root 17 Dec 16 10:31 ..
drwxr-xr-x 2 root root 6 Dec 31 12:13 container
bash-5.0$ whoami
appuser
bash-5.0$ groups
appgroup
bash-5.0$ echo hello from contanier > container.msg.txt
bash: container.msg.txt: Permission denied
Docker build command
as user osboxes
docker build -t alpine_bash_jdk11 .
Dockerfile
FROM alpine:latest
RUN apk --no-cache update
RUN apk add --no-cache bash
RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
ENV JAVA_HOME="/usr/lib/jvm/default-jvm"
ENV PATH=$PATH:${JAVA_HOME}/bin
RUN addgroup -g 1000 -S appgroup && adduser -S appuser -G appgroup -u 1000
USER appuser
I haven't used docker compose because I'm still getting my head round basic docker.
Virtual Machine which is the Docker Host
CentOS 7.2003 from osboxes.org, organization's decision, not mine
Linux osboxes 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
I did a yum update, then yum installed all the stuff needed to install VirtualBox guest additions which is working ok
Docker version 1.13.1, build 0be3e21/1.13.1
Physical Host
Windows 10 64-bit
VirtualBox 6.1.4r136177
both these are the organization's decisions
tl;dr: had old version of docker due to wrong install command
The answer: install docker-ce instead of docker. Depending on your system that might be
sudo apt-get install -y docker-ce
or
sudo yum -y install docker-ce
instead of sudo apt-get install -y docker
or
sudo yum -y install docker
Solution: update docker
Having found this article I could see that I had the wrong version of docker. I justifiably thought the correct command was
sudo yum install -y docker
but it should have been docker-ce
I had to yum erase -y docker docker-common
Now I have Docker version 20.10.1, build 831ebea

Cannot docker build because of "Couldn't run auplink before unmount" error

When I run docker build I get this:
Sending build context to Docker daemon 10.24kB
WARN[11935] Couldn't run auplink before unmount /var/lib/docker/aufs/mnt/21647778a50f097d4535246ec5206960dd909f4bb8b0e3d04fdd53a7402fc2de-init: exec: "auplink": executable file not found in $PATH
Step 1/2 : FROM debian:jessie
---> 86baf4e8cde9
Step 2/2 : RUN apt-get update
WARN[11935] Couldn't run auplink before unmount /var/lib/docker/aufs/mnt/21647778a50f097d4535246ec5206960dd909f4bb8b0e3d04fdd53a7402fc2de: exec: "auplink": executable file not found in $PATH
---> Running in 1fef9bef5bf7
ERRO[11934] containerd: start container error="shim error: fork/exec /usr/bin/docker-runc: exec format error" id=1fef9bef5bf77141a97669d2aa785e74f9027a849919a937f714e93fbae3916d
ERRO[11935] Create container failed with error: shim error: fork/exec /usr/bin/docker-runc: exec format error
ERRO[11934] containerd: deleting container error="fork/exec /usr/bin/docker-runc: exec format error: \"\""
WARN[11935] Couldn't run auplink before unmount /var/lib/docker/aufs/mnt/21647778a50f097d4535246ec5206960dd909f4bb8b0e3d04fdd53a7402fc2de: exec: "auplink": executable file not found in $PATH
shim error: fork/exec /usr/bin/docker-runc: exec format error
Here is the content of my Dockerfile:
FROM debian:jessie
RUN apt-get update
What is the issue? It makes no sens to me.
ll /usr/bin | grep docker
-rwxr-xr-x 1 root root 18471276 Aug 3 22:08 docker*
-rwxr-xr-x 1 root root 9938352 Aug 3 22:08 docker-containerd*
-rwxr-xr-x 1 root root 8941944 Aug 3 22:08 docker-containerd-ctr*
-rwxr-xr-x 1 root root 3824920 Aug 3 22:08 docker-containerd-shim*
-rwxr-xr-x 1 root root 40328816 Aug 3 22:08 dockerd*
-rwxr-xr-x 1 root root 0 Aug 3 22:08 docker-init*
-rwxr-xr-x 1 root root 0 Aug 3 22:08 docker-proxy*
-rwxr-xr-x 1 root root 0 Aug 3 22:08 docker-runc*
-rwxr-xr-x 1 root root 8962864 Aug 3 21:40 docker-volume-local-persist*
Installing from https://docs.docker.com/engine/installation/linux/docker-ce/binaries/
file $(which docker-runc):
/usr/bin/docker-runc: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=e3d80e183baf26a9d48c3f0435931d42aa1bf340, not stripped
lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 17.04
Release: 17.04
Codename: zesty
docker --version
Docker version 17.06.0-ce, build 02c1d87
dockerd --version
Docker version 17.06.0-ce, build 02c1d87
docker-containerd --version
containerd version 0.2.3 commit: cfb82a876ecc11b5ca0977d1733adbe58599088a
docker-containerd-ctr --version
ctr version 0.2.3 commit: cfb82a876ecc11b5ca0977d1733adbe58599088a
docker-init --version
tini version 0.13.0 - git.949e6fa
docker-runc --version
runc version 1.0.0-rc3
commit: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
spec: 1.0.0-rc5
Is this running on a non-Intel/ARM 64-bit Ubuntu? For example a Raspberry Pi or ARM64 CPU? This error:
shim error: fork/exec /usr/bin/docker-runc: exec format error
Would imply that either (a) the binary install on your machine is corrupted in some way, or (b) you are attempting to run a binary for a different architecture on your system.
Can you post the output of uname -a and file /usr/bin/docker-runc? That might help narrow down the source of your problem.
It looks like something related to aufs FS, What OS Do you use ? and Did you recently updated your machine ?
Update:
For CONFIG_MEMCG_SWAP_ENABLED: missing, CONFIG_RT_GROUP_SCHED: missing and warning: /proc/config.gz does not exist, searching other paths for kernel config ...
These are missing kernel configuration and flags, Please make sure you installed linux-image-extra-$(uname -r) linux-image-extra-virtual, First make sure you stopped docker daemon sudo systemctl stop docker and install these packages (contains extra driver that support containers and aufs check docker docs https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu):
sudo apt-get install \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
And update your grub GRUB_CMDLINE_LINUX_DEFAULT add thesecgroup_enable=memory swapaccount=1 to your /etc/default/grubconfiguration file then update your grub sudo update-grub check https://github.com/moby/moby/issues/4250 && https://github.com/moby/moby/pull/4251
For aufs problems there is another solution for modern dockers as docker moved from aufs to overlay and overlay2 is to configure your machine and apply overlay but make sure you backed up your docker images and containers as this fix might make you lose them check Unable to start Docker Service in Ubuntu 16.04

docker on centos that has no internet, rpm package dependency issue

I am facing an issue installing docker-ce from package on a server that has no internet access.
This is the version of my Linux | centos-release-7-2.1511.el7.centos.2.10.x86_64
Virtualization: vmware
Operating system: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
Im trying to follow the instructions as set here however since the box doesnt have internet I can't do the yum install.
So I was doing it with rpm -ivh. So far im getting dependency errors after dependency errors.
I tried these 3 versions of docker and all of them are giving out a dependency errors.
-rw-r--r--. 1 root root 19521288 Nov 8 00:52 docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 19529520 Nov 8 00:02 docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 29108 Nov 8 00:53 docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
-rw-r--r--. 1 root root 29108 Nov 8 00:03 docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm
-rw-r--r--. 1 root root 19509116 Nov 8 01:26 docker-engine-1.13.1-1.el7.centos.x86_64.rpm
-rw-r--r--. 1 root root 29024 Nov 8 01:26 docker-engine-selinux-1.13.1-1.el7.centos.noarch.rpm
rpm -ivh /docker/images/docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm
warning: /docker/images/docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
error: Failed dependencies:
docker-ce-selinux >= 17.03.2.ce-1.el7.centos is needed by docker-ce-17.03.2.ce-1.el7.centos.x86_64
rpm -ivh /docker/images/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm
warning: /docker/images/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
error: Failed dependencies:
selinux-policy-base >= 3.13.1-102 is needed by docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch
selinux-policy-targeted >= 3.13.1-102 is needed by docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch
So I tried looking for that selinux package the I found on the site below:
I tried installing the rpm from rpmfindand unfortunately, its asking for another dependency.
rpm -ivh selinux-policy-minimum-3.13.1-102.el7.noarch.rpm
warning: selinux-policy-minimum-3.13.1-102.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
policycoreutils-python >= 2.5 is needed by selinux-policy-minimum-3.13.1-102.el7.noarch
selinux-policy = 3.13.1-102.el7 is needed by selinux-policy-minimum-3.13.1-102.el7.noarch
rpm -ivh selinux-policy-targeted-3.13.1-102.el7.noarch.rpm
warning: selinux-policy-targeted-3.13.1-102.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
policycoreutils >= 2.5 is needed by selinux-policy-targeted-3.13.1-102.el7.noarch
selinux-policy = 3.13.1-102.el7 is needed by selinux-policy-targeted-3.13.1-102.el7.noarch
Has anyone tried installing docker on this version of centos before that has no access to the internet?
Do you have any easier way of getting through this?
Thank you in advance!
On a machine with internet, download all dependencies:
mkdir -p offline_repo && cd offline_repo
curl -O https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm
curl -O https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm
yum install --downloadonly --downloaddir=. docker-ce-*.rpm
You can do it on any machine (any OS) that have docker installed and internet access, you can download the dependencies within a container:
mkdir offline_repo
docker run --rm -it -v $PWD/offline_repo:/offline_repo centos:7.2.1511 \
sh -c 'cd /offline_repo \
&& curl -O https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm \
&& curl -O https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm \
&& yum install --downloadonly --downloaddir=. docker-ce-*.rpm'
Now you should have all required packages available in the offline_repo dir, which should look like this:
$ ls -1 offline_repo/
audit-libs-2.6.5-3.el7_3.1.x86_64.rpm
audit-libs-python-2.6.5-3.el7_3.1.x86_64.rpm
checkpolicy-2.5-4.el7.x86_64.rpm
docker-ce-17.03.2.ce-1.el7.centos.x86_64.rpm
docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm
iptables-1.4.21-17.el7.x86_64.rpm
libcgroup-0.41-11.el7.x86_64.rpm
libmnl-1.0.3-7.el7.x86_64.rpm
libnetfilter_conntrack-1.0.6-1.el7_3.x86_64.rpm
libnfnetlink-1.0.1-4.el7.x86_64.rpm
libseccomp-2.3.1-2.el7.x86_64.rpm
libselinux-2.5-6.el7.x86_64.rpm
libselinux-python-2.5-6.el7.x86_64.rpm
libselinux-utils-2.5-6.el7.x86_64.rpm
libsemanage-2.5-5.1.el7_3.x86_64.rpm
libsemanage-python-2.5-5.1.el7_3.x86_64.rpm
libsepol-2.5-6.el7.x86_64.rpm
libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm
policycoreutils-2.5-11.el7_3.x86_64.rpm
policycoreutils-python-2.5-11.el7_3.x86_64.rpm
python-IPy-0.75-6.el7.noarch.rpm
selinux-policy-3.13.1-102.el7_3.16.noarch.rpm
selinux-policy-minimum-3.13.1-102.el7_3.16.noarch.rpm
selinux-policy-targeted-3.13.1-102.el7_3.16.noarch.rpm
setools-libs-3.3.8-1.1.el7.x86_64.rpm
systemd-219-30.el7_3.9.x86_64.rpm
systemd-libs-219-30.el7_3.9.x86_64.rpm
Then simply copy it to the offline machine, then install all packages:
cd offline_repo
yum install -y --cacheonly --disablerepo=* *.rpm

Jenkins fails when running "service start jenkins"

I installed jenkins on Centos 7 using the following:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins
as described on the official documentation
However when I run:
service start jenkins
I get the following error message:
Starting jenkins (via systemctl): Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
[FAILED]
Running systemctl status jenkins.service gives me this:
● jenkins.service - LSB: Jenkins Continuous Integration Server
Loaded: loaded (/etc/rc.d/init.d/jenkins)
Active: failed (Result: exit-code) since Wed 2016-09-21 16:45:28 BST; 3min 59s ago
Docs: man:systemd-sysv-generator(8)
Process: 2818 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.JavaVMArguments.of(JavaVMArguments...04)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.JavaVMArguments.current(JavaVMArgu...92)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.Daemon.daemonize(Daemon.java:106)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.Daemon.all(Daemon.java:88)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: ... 6 more
Sep 21 16:45:28 webstack.local.caplib systemd[1]: jenkins.service: control process exited, code=exited s...s=1
Sep 21 16:45:28 webstack.local.caplib systemd[1]: Failed to start LSB: Jenkins Continuous Integration Server.
Sep 21 16:45:28 webstack.local.caplib systemd[1]: Unit jenkins.service entered failed state.
Sep 21 16:45:28 webstack.local.caplib systemd[1]: jenkins.service failed.
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: [FAILED]
Hint: Some lines were ellipsized, use -l to show in full.
and running journalctl -xe gives me this:
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.Daemon.daemonize(Daemon.java:106)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: at com.sun.akuma.Daemon.all(Daemon.java:88)
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: ... 6 more
Sep 21 16:45:28 webstack.local.caplib runuser[2819]: pam_unix(runuser:session): session closed for user jenkin
Sep 21 16:45:28 webstack.local.caplib systemd[1]: jenkins.service: control process exited, code=exited status=
Sep 21 16:45:28 webstack.local.caplib systemd[1]: Failed to start LSB: Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit jenkins.service has failed.
--
-- The result is failed.
Sep 21 16:45:28 webstack.local.caplib systemd[1]: Unit jenkins.service entered failed state.
Sep 21 16:45:28 webstack.local.caplib systemd[1]: jenkins.service failed.
Sep 21 16:45:28 webstack.local.caplib jenkins[2818]: [FAILED]
Sep 21 16:45:28 webstack.local.caplib polkitd[1392]: Unregistered Authentication Agent for unix-process:2813:8
Sep 21 16:45:28 webstack.local.caplib dhclient[1390]: DHCPREQUEST on eno16777984 to 192.168.15.254 port 67 (xi
Sep 21 16:45:28 webstack.local.caplib dhclient[1390]: DHCPACK from 192.168.15.254 (xid=0x2ab6e6bc)
Sep 21 16:45:30 webstack.local.caplib dhclient[1390]: bound to 192.168.15.120 -- renewal in 865 seconds.
Sep 21 16:45:36 webstack.local.caplib systemd[1]: Starting Cleanup of Temporary Directories...
-- Subject: Unit systemd-tmpfiles-clean.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has begun starting up.
Sep 21 16:45:36 webstack.local.caplib systemd[1]: Started Cleanup of Temporary Directories.
-- Subject: Unit systemd-tmpfiles-clean.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-tmpfiles-clean.service has finished starting up.
--
-- The start-up result is done.
Both of which is really unhelpful. How do I fix this issue?
Similar problem on Ubuntu 16.04.
Setting up jenkins (2.72) ...
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
invoke-rc.d: initscript jenkins, action "start" failed.
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2017-08-01 05:39:06 UTC; 7ms ago
Docs: man:systemd-sysv-generator(8)
Process: 3700 ExecStart=/etc/init.d/jenkins start (code=exited, status=1/FAILURE)
Aug 01 05:39:06 ip-0 systemd[1]: Starting LSB: Start Jenkins ....
Aug 01 05:39:06 ip-0 jenkins[3700]: ERROR: No Java executable ...
Aug 01 05:39:06 ip-0 jenkins[3700]: If you actually have java ...
Aug 01 05:39:06 ip-0 systemd[1]: jenkins.service: Control pro...1
Aug 01 05:39:06 ip-0 systemd[1]: Failed to start LSB: Start J....
Aug 01 05:39:06 ip-0 systemd[1]: jenkins.service: Unit entere....
Aug 01 05:39:06 ip-0 systemd[1]: jenkins.service: Failed with....
To fix the issue manually install Java Runtime Environment:
JDK version 9:
sudo apt install openjdk-9-jre
JDK version 8:
sudo apt install openjdk-8-jre
Open Jenkins configuration file:
sudo vi /etc/init.d/jenkins
Finally, append path to the new java executable (line 16):
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/lib/jvm/java-8-openjdk-amd64/bin/
ERROR: Linux / Centos:
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
Solution:
Edit the Jenkins init file by doing
sudo vi /etc/init.d/jenkins
Add your own Java path, for example:
/opt/oracle/product/java/jdk1.8.0_45/bin/java
Restart the service:
sudo service jenkins start
sudo service jenkins status
sudo service jenkins stop
I had a similar problem on Ubuntu 16.04. Thanks to #Guna I figured out that I had to manually install Java (sudo apt install openjdk-8-jre).
I had a similar issue on CentOS 7 while a correct version of Java was installed and java -version gave a nice result.
Collecting multiple answers from different SO threads I did the following:
Make sure Java is installed (and version is compatible with Jenkins)
There're some tricks if saying about CentOS, this is mentioned in official Jenkins tutorial here
If Java is installed and available, when running java -v output should look like this:
~>$java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
Add a path to Java to your /etc/rc.d/init.d/jenkins
~>$ sudo vim /etc/rc.d/init.d/jenkins
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
/usr/java/jdk1.8.0_162/bin/java ##add your java path here
"
How to get your 'real' path to java distributive which is called when you type smth like java -v
Follow this SO thread
If steps above didn't help, try to make sure all permission issues are resolved:
If Jenkins fails to run Java, it could be jenkins user doesn't have permissions to run it, then change jenkins to root in config (described here)
Try to play with chmod setting 755 permissions to java installation folder
And finally what helped me in result
When I did run journalctl -xe as was suggested when I've tried to sudo service jenkins start, I got similar Java stacktrace:
Starting CloudBees Jenkins Enterprise Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at Main._main(Main.java:140)
at Main.main(Main.java:98)
Caused by: java.lang.UnsatisfiedLinkError: /tmp/jna--1712433994/jna7387046629130767794.tmp: /tmp/jna--1712433994/jna7387046629130767794.tmp: failed to map segment from shared object: Operation not permitted
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1822)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
at com.sun.jna.Native.<clinit>(Native.java:131)
at com.sun.akuma.CLibrary.<clinit>(CLibrary.java:89)
at com.sun.akuma.JavaVMArguments.resolvePID(JavaVMArguments.java:128)
at com.sun.akuma.JavaVMArguments.ofLinux(JavaVMArguments.java:116)
at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:104)
at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.java:92)
at com.sun.akuma.Daemon.daemonize(Daemon.java:106)
at com.sun.akuma.Daemon.all(Daemon.java:88)
... 6 more
The problem is that Jenkins tries to launch JNA library from /tmp dir which is marked as noexec by default, so we it could be fixed by creating a temporary directory in a /jenkins path so it could be executed.
The full way to do this is described here by CloudBees support (thanks a lot for them)
I hope something from this list will help (as well I mostly leave it for me in the future when I'll have to install Jenkins for CentOs again :)
Before you install Jenkins you should install JDK:
apt install openjdk-8-jre
After this install Jenkins:
apt-get install jenkins
And check Jenkins status (should be 'active'):
systemctl status jenkins.service
The easiest possible fix for this issue if it is a AWS linux instance
sudo yum install java-1.8.0 -y
sudo yum remove java-1.7.0-openjdk
Still fighting the same error on both ubuntu, ubuntu derivatives and opensuse. This is a great way to bypass and move forward until you can fix the actual issue.
Just use the docker image for jenkins from dockerhub.
docker pull jenkins/jenkins
docker run -itd -p 8080:8080 --name jenkins_container jenkins
Use the browser to navigate to:
localhost:8080 or my_pc:8080
To get at the token at the path given on the login screen:
docker exec -it jenkins_container /bin/bash
Then navigate to the token file and copy/paste the code into the login screen. You can use the edit/copy/paste menus in the kde/gnome/lxde/xfce terminals to copy the terminal text, then paste it with ctrl-v
War File
Or use the jenkins.war file. For development purposes you can run jenkins as your user (or as jenkins) from the command line or create a short script in /usr/local or /opt to start it.
Download the jenkins.war from the jenkins download page:
https://jenkins.io/download/
Then put it somewhere safe, ~/jenkins would be a good place.
mkdir ~/jenkins; cp ~/Downloads/jenkins.war ~/jenkins
Then run:
nohup java -jar ~/jenkins/jenkins.war > ~/jenkins/jenkins.log 2>&1
To get the initial admin password token, copy the text output of:
cat /home/my_home_dir/.jenkins/secrets/initialAdminPassword
and paste that into the box with ctrl-v as your initial admin password.
Hope this is detailed enough to get you on your way...
I had the same issue, and when I checked if Java is installed I realised it's not, so installing Java solved the problem for me.
Check for java:
java -version
If Java is installed in the system, the command will return the java version otherwise it will show a message like this.
The program 'java' can be found in the following packages:
* default-jre
* gcj-5-jre-headless
* openjdk-8-jre-headless
* gcj-4.8-jre-headless
* gcj-4.9-jre-headless
* openjdk-9-jre-headless
To install java use the following command.
sudo apt-get install default-jre
[100 %]Solved. I had the same problem today. I checked my server space
df-h
I saw that server is out of space so i check which directory has most size by
sudo du -ch / | sort -h
I saw 12.2G /var/lib/jenkins so i entered this folder and cleared all the logs by
cd /var/libs/jenkins
rm *
and restart the jenkins it will work normal
sudo systemctl restart jenkins.service
I was trying to install it in kubuntu 18.04, and i was already sure that i had java installed,
I confirmed by trying
java -version
I got the output like that
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Since I already know that my java PATH variables are defined in /etc/environment file, I added that file to the top of /etc/init.d/jenkins file
source /etc/environment
you can even remove the PATH from /etc/init.d/jenkins file, since it's already defined in /etc/environment
after that, i restarted my jenkins server,and it seemed to start working fine from localhost:8080
In my case, the port 8080 was taken by some other service (Apache Airflow).
So I edit the HTTP port in this file:
sudo vi /etc/default/jenkins
And then started the service and it worked:
sudo service jenkins start
I was on Ubuntu 18.04 and installed openjdk-8
Jenkins, by default, makes use of port 8080, please make sure its not occupied by other applications.
To check if a port is available, try running
curl localhost:8080
If port is available, this should result in an error like:
curl: (7) Failed to connect to localhost port 8080: Connection refused
If the port is occupied, Jenkins port can be changed by:
sudo systemctl edit --full jenkins.service
and setting:
Environment="JENKINS_PORT=<ANY_AVAILABLE_PORT>"
Then run:
sudo systemctl restart jenkins.service
For ubuntu 16.04, there is firewall issue. You need to open 8080 port using following command:
sudo ufw allow 8080
Detailed steps are given here: https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-16-04
Installing Java fixed this issue for me!
please try to install it like this:
sudo apt install openjdk-11-jdk
Amazon linux
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
amazon-linux-extras install epel
amazon-linux-extras install java-openjdk11
yum install jenkins
systemctl start jenkins
---just follow steps--
Adding on to what has been already answered by Guna Sekaran. Jenkins need the user jenkins to be present in order to run the jenkins as a service.
To add user fire 'useradd jenkins' as root
and fire 'passwd jenkins' as root before starting Jenkins as a service.
~>$ sudo vim /etc/rc.d/init.d/jenkins
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
/usr/java/jdk1.8.0_162/bin/java ##add your java path
"
You just need to install Java.
It did work after installing Java version 8,
using this command : sudo apt install openjdk-8-jre-headless
Looks like java version conflicts.
Please refer https://medium.com/lucian-daniliuc/upgrading-jenkins-on-ubuntu-14-04-lts-df3e1209f98c
I faced same issue while setting up jenkins, the problem is that java is not installed and hence not available in path.
The simplest way is to use scp here to copy jdk binaries to aws ec2 box, script won't work if you make one as they keep on updating download urls(Orale, i mean):
scp -i C:/Users/key-pair.pem jdk-8u191-linux-x64.tar.gz ec2-
user#54.183.220.7:~/
$cd /opt
$sudo cp /home/ec2-user/jdk* .
$sudo chmod +x jdk*
$sudo tar xzf jdk-8u191-linux-x64.tar.gz
$sudo tar xzf jdk-8u191-linux-x64.tar.gz
$cd jdk1.8.0_191/
$sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_191/bin/java 2
$sudo alternatives --config java
Here I download tar.gz file in loal windows and transferred over scp to AWS ec2-user, default dir. Hope it helps.
I had below error:
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
Solution was to revert the NAME to jenkins in the below file (Earlier I have changed it to 'NAME=ubuntu'):
sudo vi /etc/default/jenkins
NAME=jenkins
Now restart passed:
sudo service jenkins restart
sudo systemctl restart jenkins.service
Hope that helps.
In my case, the issue was of unsupported java version
Check the file /etc/init.d/jenkins to find out which java versions are supported.
To find which java versions are supported, run
grep -m 1 "JAVA_ALLOWED_VERSIONS" /etc/init.d/jenkins
The output will be like this(your's might be different)
JAVA_ALLOWED_VERSIONS=( "1.8" "11" )
In my case version 1.8 and 11 are supported. I will be going with version 11.
Install the supported version of jre using command
For ubuntu/debian
sudo apt install openjdk-11-jre
For centOS use
sudo yum install java-11-openjdk-devel
Find the path to newly installed jre
For ubuntu/debian path is
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
You can find the path on centOS under /usr/lib/jvm/
Modify the file /etc/init.d/jenkins
At line number 28, replace the JAVA=`type -p java` with JAVA='/usr/lib/jvm/java-11-openjdk-amd64/bin/java'
Now run command to reload the systemctl daemon
sudo systemctl daemon-reload
Start the jenkins service
sudo systemctl start jenkins
[root~]# systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
[root~]#
[root~]# systemctl status jenkins.service
● jenkins.service - LSB: Jenkins Automation Server
Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2021-08-26 03:31:13 UTC; 12s ago
Docs: man:systemd-sysv-generator(8)
Process: 3465 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)
Aug 26 03:31:13 ip-172-31-11-0.ap-south-1.compute.internal systemd[1]: Starting LSB: Jenkins Automation Server...
Aug 26 03:31:13 ip-172-31-11-0.ap-south-1.compute.internal jenkins[3465]: Starting Jenkins File "/usr/bin/java" is not executable.
Aug 26 03:31:13 ip-172-31-11-0.ap-south-1.compute.internal jenkins[3465]: [FAILED]
Aug 26 03:31:13 ip-172-31-11-0.ap-south-1.compute.internal systemd[1]: jenkins.service: control process exited, code=exited status=1
Aug 26 03:31:13 ip-172-31-11-0.ap-south-1.compute.internal systemd[1]: Failed to start LSB: Jenkins Automation Server.
Aug 26 03:31:13 ip-172-31-11-0.ap-south-1.compute.internal systemd[1]: Unit jenkins.service entered failed state.
Aug 26 03:31:13 ip-172-31-11-0.ap-south-1.compute.internal systemd[1]: jenkins.service failed.
I had this problem. and the problem was that I haven't installed java. This is for Amazon Linux. To install Java on Amazon Linux use : sudo yum install java.
same error in my case,I tried all the above solutions ,none of them work because java is not the problem here.Please follow this steps for success.
before hitting sudo yum install jenkins java-1.8.0-openjdk-devel -y, you need to proceed this below step
step1: sudo amazon-linux-extras install epel -y
step2:sudo vi vim /etc/yum.repos.d/epelfordaemonize.repo (it will open vim)
step3:Enter this command after step2(vim is open)
[daemonize]
baseurl=https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/
gpgcheck=no
enabled=yes
step4: For saving those command, type :wq and hit enter again write :wq and hit enter,it will save and return back.
step5: Now,sudo yum install jenkins java-1.8.0-openjdk-devel -y,it will work
Install the certificates-
sudo apt install ca-certificates
then,
Try Updating & Upgrading the packages-
sudo apt upgrade
sudo apt update
Then follow the link to install the Jenkins :)
https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-ubuntu-18-04
I use docker for jenkins.
You should be use https://hub.docker.com/r/jenkins/jenkins instead https://hub.docker.com/_/jenkins
First, install JDK version 8:
sudo apt install openjdk-8-jre
Second, Choose version 8 as your default java environment by simply running
sudo update-alternatives --config java
Finally, Run
sudo systemctl start jenkins
Now, open port 8080 to login to Jenkins!
To stop it run:
sudo systemctl stop jenkins
In my case, my first error where I got the error message above was due to /usr/share/jenkins/jenkins.war missing. I had manually set it as a symlink, and running apt-get upgrade removed the symlink.
Fix was to download the latest jenkins.war from jenkins.io (or restoring the symlink to point to the latest version).
After this I still got the same error, and by starting Jenkins manually:
java -jar jenkins.war
I got the following error message
SEVERE: Running with Java class version 52, which is older than the Minimum required version 55. See https://jenkins.io/redirect/java-support/
Jenkins requires Java versions [17, 11] but you are running with Java 1.8
Upgrading openjdk to version 11 (or 17) solved the problem:
apt-get install openjdk-11-jre
vi /etc/init.d/jenkins
add:
/usr/lib/jvm/java/jre/bin/java
In my case I were starting jenkins service from root instead of jenkins user
i did
sed -i 's/JENKINS_USER="jenkins"/JENKINS_USER="root"/g /etc/sysconfig/jenkins
then
service jenkins restart
all work well

Resources