docker - tomcat8 on centos 7 - docker

I am trying to deploy a war to tomcat 8 on centos 7. I am getting the following error while deploying a war into the tomcat 8.
Caused by: org.postgresql.util.PSQLException: ERROR: could not load library "/usr/pgsql-9.3/lib/plperl.so": /usr/pgsql-9.3/lib/plperl.so: undefined symbol: errcontext
Where: PL/pgSQL function db.c_scr(text,text,text,text,text,text,text,text,date,date,character,character,boolean,boolean,text,character,text,text,character,text,character varying,text,text,boolean,text,text,boolean,character,text,text,text) line 1285 at FOR over EXECUTE statement
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2412) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2125) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:297) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:301) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:287) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:264) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:231) ~[postgresql-42.0.0.jre6.jar:42.0.0.jre6]
at org.apache.tomcat.dbcp.dbcp2.DelegatingStatement.executeQuery(DelegatingStatement.java:254) ~[tomcat-dbcp.jar:8.5.47]
at org.apache.tomcat.dbcp.dbcp2.DelegatingStatement.executeQuery(DelegatingStatement.java:254) ~[tomcat-dbcp.jar:8.5.47]
at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:452) ~[spring-jdbc-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:402) ~[spring-jdbc-4.0.6.RELEASE.jar:4.0.6.RELEASE]
FROM centos:7
RUN ./initialize_env.sh
initialize_env.sh is as follows.
yum -y update && yum clean all
yum -y install unzip wget httpd httpd-devel gcc* make && yum clean all
# Install mod_jk
curl -SL https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz -o tomcat-connectors-1.2.40-src.tar.gz \
&& mkdir -p src/tomcat-connectors \
&& tar xzf tomcat-connectors-1.2.40-src.tar.gz -C src/tomcat-connectors --strip-components=1 \
&& cd src/tomcat-connectors/native/ \
&& ./configure --with-apxs=/usr/bin/apxs \
&& make \
&& cp apache-2.0/mod_jk.so /usr/lib64/httpd/modules/ \
&& ./libtool --finish /usr/lib64/httpd/modules/ \
&& cd / \
&& rm -rf src/ \
&& rm -f tomcat-connectors-1.2.40-src.tar.gz
echo "Downloading tomcat"
cd /apps/
wget http://apache.mirrors.pair.com/tomcat/tomcat-8/v8.5.47/bin/apache-tomcat-8.5.47.zip
unzip apache-tomcat-8.5.47.zip
mv apache-tomcat-8.5.47 tomcat
chmod -R 755 tomcat
chmod -R +x tomcat/bin
yum -y install postgresql-plperl
yum -y install java
wget https://download.postgresql.org/pub/repos/yum/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-3.noarch.rpm
rpm -ivh pgdg-centos93-9.3-3.noarch.rpm
yum -y install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel postgresql93-plperl
After this installation, i see this output.
sh-4.2# ls -l /usr/pgsql-9.3/lib/plperl.so
-rwxr-xr-x 1 root root 87304 Nov 7 2018 /usr/pgsql-9.3/lib/plperl.so
I need to run Apache Web server with Tomcat. I have a postgres jdbc driver (version 9) under $tomcat_home/lib directory. I even tried a higher version of jdbc driver, but it is still throwing the same error.
does anybody know why?
Is there anything else that I need to do?

Related

404 error for some packages when building docker image

when building docker image for gitlab runner base image getting error as :
ERRO[2021-12-29T09:46:32Z] Application execution failed PID=6622 error="executing the script on the remote host: executing script on container with IP \"3.x.x.x\": connecting to server: connecting to server \"3.x.x.x:x\" as user \"root\": dial tcp 3.x.x.x:x: connect: connection refused"
ERROR: Job failed (system failure): prepare environment: exit status 2. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
Dockerfile:
FROM registry.gitlab.com/tmaczukin-test-projects/fargate-driver-debian:latest
RUN apt-get install -y wget && \
apt-get install -y python3-pip && \
wget https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip && \
unzip terraform_0.12.24_linux_amd64.zip
mv terraform /usr/local/bin && \
chmod -R 777 /usr/local/bin
I'm assuming the error mentioned in the title is from the apt-get install commands. You should be running an apt-get update first to get an updated package list. Otherwise apt will be looking for packages from a stale state (whenever the base image was created). You can also merge the install commands and include a cleanup of temporary files in the same step to reduce layer size.
FROM registry.gitlab.com/tmaczukin-test-projects/fargate-driver-debian:latest
RUN apt-get update && \
apt-get install -y \
python3-pip \
wget && \
wget https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip && \
unzip terraform_0.12.24_linux_amd64.zip
mv terraform /usr/local/bin && \
chmod -R 777 /usr/local/bin && \
rm terraform_0.12.24_linux_amd64.zip && \
rm -rf /var/lib/apt/lists/*

Error trying to install Python inside a Docker container

I am relatively new to docker. I have an application which I want to containerize.
Below is is my docker file:
FROM ubuntu:16.04
## ENV Variables
ENV PYTHON_VERSION="3.6.5"
# Update and Install packages
RUN apt-get update -y \
&& apt-get install -y \
curl \
wget \
tar
# Install Python 3.6.5
RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz \
&& tar -xvf Python-${PYTHON_VERSION}.tar.xz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure \
&& make altinstall \
&& cd / \
&& rm -rf Python-${PYTHON_VERSION}
# Install Google Cloud SDK
# Downloading gcloud package
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz > /tmp/google-cloud-sdk.tar.gz
# Installing the package
RUN mkdir -p /usr/local/gcloud \
&& tar -C /usr/local/gcloud -xvf /tmp/google-cloud-sdk.tar.gz \
&& /usr/local/gcloud/google-cloud-sdk/install.sh
# Adding the package path to local
ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin
I am trying to install python3.6.5 version but I am receiving the following error.
020-01-09 17:26:13 (107 KB/s) - 'Python-3.6.5.tar.xz' saved [17049912/17049912]
tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
The command '/bin/sh -c wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz && tar -xvf Python-${PYTHON_VERSION}.tar.xz && cd Python-${PYTHON_VERSION} && ./configure && make altinstall && cd / && rm -rf Python-${PYTHON_VERSION}' returned a non-zero code: 2
Decompressing an .xz file requires the xz binary which under ubuntu is provided by the package xz-utils So You have to instal xz-utils on your image prior to decompressing an .xz file.
You can add this to your previous apt-get install run:
# Update and Install packages
RUN apt-get update -y \
&& apt-get install -y \
curl \
wget \
tar \
xz-utils
This should fix the following call to tar in the next RUN expression
Instead of trying to install Python, just start with a base image that has Python preinstalled, e.g. python:3.6-buster. This image is based on Debian Buster, which was released in 2019. Since Ubuntu is based on Debian, everything will be pretty similar, and since it's from 2019 (as opposed to Ubuntu 16.04, which is from 2016) you'll get more up-to-date software.
See https://pythonspeed.com/articles/base-image-python-docker-images/ for longer discussion.

Docker issue : Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) : Chrome Browser and Driver 78

I recently updated Chrome Browser to 78 version, and it has caused an issue.
I am running Selenium tests inside Linux Docker container in Headless Chrome mode, with latest chrome-78.0.3904.108, driver-78.0.3904.105 and selenium- 3.141.0, specflow packages -3.1.67.
I have tried almost all capabilities suggested on this forum to run Chrome headlessly inside Docker.
case "Headless_Chrome":
string driverPath = "/opt/selenium/";
string driverExecutableFileName = "chromedriver";
ChromeDriverService service_headless = ChromeDriverService.CreateDefaultService(driverPath, driverExecutableFileName);
chrome_options.BinaryLocation = "/opt/google/chrome/chrome";
chrome_options.AddArgument("--no-sandbox");
chrome_options.AddArgument("--headless");
chrome_options.AddArgument("--window-size=1420,1080");
chrome_options.AddArgument("--disable-extensions");
chrome_options.AddArgument("--proxy-server='direct://'");
chrome_options.AddArgument("--proxy-bypass-list=*");
chrome_options.AddArgument("--disable-gpu"); //even will come redundant in case of linux
chrome_options.AddArgument("--disable-dev-shm-usage"); // to fix - error: unknown error: session deleted because of page crash
chrome_options.AddArgument("--remote-debugging-port=9222");
chrome_options.AddArgument("--remote-debugging-address=0.0.0.0");
chrome_options.AddArgument("--disable-infobars");
chrome_options.AddArgument("--user-data-dir=/data");
chrome_options.AddArgument("--disable-features=VizDisplayCompositor"); //to save from zombie chrome process running
//chrome_options.AddArgument("--disable-setuid-sandbox");
//chrome_options.AddArgument("--privileged"); // can be a security risk
//chrome_options.AddArgument("--lang=en_US");
//chrome_options.AddArgument("--start-maximized");
//chrome_options.AddAdditionalCapability("useAutomationExtension", false);
driver = new ChromeDriver(service_headless, chrome_options, TimeSpan.FromSeconds(120));
break;
My Docker file(License key is replaced with xxxxx ) :
FROM microsoft/dotnet:2.2-sdk
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN dotnet tool install --global SpecFlow.Plus.License
RUN specflow-plus-license register --licenseKey KBD0xxxxxxxxxxxxxxxxxxxxiqQGIUTnUBAU/wn/EAAA== --issuedTo "xxxxxxxxxxxxxx"
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV C en_US.UTF-8
ENV TERM xterm
ENV TZ Europe/Copenhagen
USER root
# Install Chrome
RUN apt-get update && apt-get install -y \
apt-transport-https ca-certificates curl gnupg hicolor-icon-theme \
libcanberra-gtk* libgl1-mesa-dri libgl1-mesa-glx libpango1.0-0 libpulse0 \
libv4l-0 fonts-symbola \
--no-install-recommends \
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update && apt-get install -y google-chrome-stable --no-install-recommends \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /var/lib/apt/lists/*
#RUN dpkg -s google-chrome-stable
#RUN apt-get update && apt-get search google-chrome-stable && apt-get show google-chrome-stable
# Download the google-talkplugin And ChromeDrive
ARG CHROME_DRIVER_VERSION="latest"
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl unzip \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sSL "https://dl.google.com/linux/direct/google-talkplugin_current_amd64.deb" -o /tmp/google-talkplugin-amd64.deb \
&& dpkg -i /tmp/google-talkplugin-amd64.deb \
&& rm -rf /tmp/*.deb \
&& CD_VERSION=$(if [ ${CHROME_DRIVER_VERSION:-latest} = "latest" ]; then echo $(wget -qO- https://chromedriver.storage.googleapis.com/LATEST_RELEASE); else echo $CHROME_DRIVER_VERSION; fi) \
&& echo "Using chromedriver version: "$CD_VERSION \
&& mkdir /opt/selenium \
&& curl -sSL "https://chromedriver.storage.googleapis.com/$CD_VERSION/chromedriver_linux64.zip" -o /tmp/chromedriver.zip \
&& unzip -o /tmp/chromedriver -d /opt/selenium/ \
&& rm -rf /tmp/*.zip \
&& apt-get purge -y --auto-remove curl unzip
# Add chrome user
RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome \
&& mkdir -p /home/chrome/Downloads && chown -R chrome:chrome /home/chrome
#ENV DISPLAY=:99
WORKDIR /data/WebShopTestAutomation
# copy code
RUN mkdir -p /data && mkdir /reports
COPY ./source /data
RUN ls -ls /data
RUN cd /data/WebShopTestAutomation && dotnet build
CMD ["dotnet", "vstest", "--logger:trx;LogFileName=/reports/TestResults/report.trx", "/data/WebShopTestAutomation/bin/Debug/netcoreapp2.2/WebShopTestAutomation.dll"]
Closing this issue,
as Root cause was this : default.srprofile which was used in project was not working in Docker, it is just not read.
Have raised a issue at Git hub Specflow
For details:
https://github.com/techtalk/SpecFlow/issues/1841

docker run error: Unable to access jarfile

Docker image is built but when I want to run it, it shows this error:
Error: Unable to access jarfile rest-service-1.0.jar
My OS is Ubuntu 18.04.1 LTS and I use docker build -t doc-service & docker run doc-service.
This is my Dockerfile:
FROM ubuntu:16.04
MAINTAINER Frederico Apostolo <frederico.apostolo#blockfactory.com> (#fapostolo)
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y software-properties-common python-software-properties language-pack-en-base
RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update && apt-get update --fix-missing && apt-get -y --allow-downgrades --allow-remove-essential --allow-change-held-packages upgrade \
&& echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections \
&& apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages curl vim unzip wget oracle-java8-installer \
&& apt-get clean && rm -rf /var/cache/* /var/lib/apt/lists/*
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle/
run java -version
run echo $JAVA_HOME
#use locate for debug
RUN apt-get update && apt-get install -y locate mlocate && updatedb
#LIBREOFFICE START
RUN apt-get update && apt-get update --fix-missing && apt-get install -y -q libreoffice \
libreoffice-writer ure libreoffice-java-common libreoffice-core libreoffice-common \
fonts-opensymbol hyphen-fr hyphen-de hyphen-en-us hyphen-it hyphen-ru fonts-dejavu \
fonts-dejavu-core fonts-dejavu-extra fonts-noto fonts-dustin fonts-f500 fonts-fanwood \
fonts-freefont-ttf fonts-liberation fonts-lmodern fonts-lyx fonts-sil-gentium \
fonts-texgyre fonts-tlwg-purisa
#LIBREOFFICE END
#font configuration
COPY 00-odt-template-renderer-fontconfig.conf /etc/fonts/conf.d
RUN mkdir /document-service /document-service/fonts /document-service/module /document-service/logs
# local settings
RUN echo "127.0.0.1 http://www.arbs.local http://arbs.local www.arbs.local arbs.local" >> /etc/hosts
# && mkdir /logs/ && echo "dummy" >> /logs/errors.log
#EXPOSE 2115
COPY document-service-java_with_user_arg.sh /
RUN chmod +x /document-service-java_with_user_arg.sh
RUN apt-get update && apt-get -y --no-install-recommends install \
ca-certificates \
curl
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
RUN curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.4/gosu-$(dpkg --print-architecture)" \
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.4/gosu-$(dpkg --print-architecture).asc" \
&& gpg --verify /usr/local/bin/gosu.asc \
&& rm /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu
ENV LANG="en_US.UTF-8"
# In case someone loses the Dockerfile
# Needs to be in the end so it doesn't invalidate unaltered cache whenever the file is updated.
RUN rm -rf /etc/Dockerfile
ADD Dockerfile /etc/Dockerfile
ENTRYPOINT ["/document-service-java_with_user_arg.sh"]
this is document-service-java_with_user_arg.sh:
#!/bin/bash
USER_ID=${LOCAL_USER_ID:-9001}
USER_NAME=${LOCAL_USER_NAME:-jetty}
echo "Starting user: $USER_NAME with UID : $USER_ID"
useradd --shell /bin/bash --home-dir /document-service/dockerhome --non-unique --uid $USER_ID $USER_NAME
cd /document-service
/usr/local/bin/gosu $USER_NAME "$#" java -jar rest-service-1.0.jar
Can anyone help me on this?
Based on the comments, you must add the JAR when building the image by defining in your Dockerfile :
COPY rest-service-1.0.jar /document-service/rest-service-1.0.jar
You could also just use :
COPY rest-service-1.0.jar /rest-service-1.0.jar
, and remove cd /document-service in your entrypoint script, as on ubuntu:16.04 images, default working directory is /. My opinion is that setting the working directory in the script is safer, so you should just go for the first solution.
Note that you could also use ADD instead of COPY (as you already did in your Dockerfile), but here only COPY is necessary (read this post if you want more info : What is the difference between the `COPY` and `ADD` commands in a Dockerfile?).
Finally, I suggest you to add the COPY line at the end of your Dockerfile, so that if a new JAR is built, image won't be rebuilt from scratch but from an existing layer, speeding up build time.
it looking error about workdir
you must select workdir for this copy format
try WORKDIR /yourpath/

can anyone let me know what is the issue in my docker file?

i need a container running with java installed in it and i want to expose the port 8090.
Here is the Docker file i have written to achieve this.
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
ENV VERSION 8
ENV UPDATE 152
ENV BUILD 16
ENV SIG aa0333dd3019491ca4f6ddbe78cdb6d0
ENV JAVA_HOME /usr/lib/jvm/java-${VERSION}-oracle
# install jre
RUN apt-get update -qq && \
apt-get upgrade -qqy --no-install-recommends && \
apt-get install curl unzip bzip2 -qqy && \
mkdir -p "${JAVA_HOME}" && \
curl --silent --location --insecure --junk-session-cookies --retry 3 \
--header "Cookie: oraclelicense=accept-securebackup-cookie;" \
http://download.oracle.com/otn-pub/java/jdk/"${VERSION}"u"${UPDATE}"-b"${BUILD}"/"${SIG}"/jre-"${VERSION}"u"${UPDATE}"-linux-x64.tar.gz \
| tar -xzC "${JAVA_HOME}" --strip-components=1 && \
apt-get remove --purge --auto-remove -y curl unzip bzip2 && \
apt-get autoclean && apt-get --purge -y autoremove && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN update-alternatives --install "/usr/bin/java" "java" "${JAVA_HOME}/bin/java" 1 && \
update-alternatives --install "/usr/bin/javaws" "javaws" "${JAVA_HOME}/bin/javaws" 1 && \
update-alternatives --set java "${JAVA_HOME}/bin/java" && \
update-alternatives --set javaws "${JAVA_HOME}/bin/javaws"
EXPOSE 8090
Using the Dockerfile i was able to successfully build the image and i have pushed to my account in hub.docker.com
but when i run try to run the container using the following command , The Container was not running.
i broked my head analyzing the root cause more than 2 hours i was not able to find the problem.
I know i am missing something silly, can anyone have a look and point the mistake i am doing?
Thanks in advance
Your Dockerfile is missing an ENTRYPOINT or CMD instruction. They define what command is run when starting the container.
Reference CMD
Reference ENTRYPOINT
You didn't define a ENTRYPOINT or CMD.
Some useful links:
What is the difference between CMD and ENTRYPOINT in a Dockerfile?
https://www.ctl.io/developers/blog/post/dockerfile-entrypoint-vs-cmd/
https://docs.docker.com/engine/reference/builder/#known-issues-run

Resources