Trouble in installing Openjdk-8 in Debian Jessie - docker

I am trying to install jdk-8 in debian jessie docker containier. Below is the docker file
FROM debian:jessie
ENV DEBIAN_FRONTEND noninteractive
RUN \
echo deb http://http.debian.net/debian jessie-backports main >> /etc/apt/sources.list &&\
apt-get update && apt-get install openjdk-8-jdk &&\
update-alternatives --config java
I am getting the below error
The following packages have unmet dependencies:openjdk-8-jdk : Depends: openjdk-8-jre (= 8u131-b11-1~bpo8+1) but it is not going to be installed.Depends: openjdk-8-jdk-headless (= 8u131-b11-1~bpo8+1) but it is not going to be installed E: Unable to correct problems, you have held broken packages.The command '/bin/sh -c echo deb http://http.debian.net/debian jessie-backports main >> /etc/apt/sources.list && apt-get update && apt-get install openjdk-8-jdk && update-alternatives --config java' returned a non-zero code: 100
Please let me know how to solve this issue.

You should use below to install jdk
apt-get install -t jessie-backports openjdk-8-jdk

Below changes worked for me
apt-get -y update && apt-get install -y -t jessie-backports ca-certificates-java && apt-get -y install openjdk-8-jdk && update-alternatives --config java

Related

Building a docker container on top of another image... "permission denied"?

I am trying to build an extension of an existing image with FROM and then apt install additional packages on top and do own customizations. I get permission denied and "are you root" messages. Specifically, this is the image I want to extend:
https://hub.docker.com/r/makarius/isabelle
My Dockerfile:
FROM makarius/isabelle:latest
SHELL ["/bin/bash", "-c"]
# Add dependencies
RUN apt-get update && \
apt-get install --yes build-essential && \
apt-get install --yes openjdk-8-jdk && \
apt-get install --yes xterm && \
apt-get install --yes iputils-ping && \
apt-get install --yes vim && \
apt-get install --yes net-tools && \
apt-get -y install xauth && \
apt-get clean
# user
RUN useradd -m foo && (echo foo:foo | chpasswd)
USER foo
# Setup FOO repository
WORKDIR /home/foo
# ... some commands
ENTRYPOINT ["/bin/bash"]
Building it it seems I can't get the ability to install anything. There is no sudo in the image.
root#ub18:/home/x/foo/bar# sudo docker build -t i8:01 -f Dockerfile .
Sending build context to Docker daemon 408.7MB
Step 1/9 : FROM makarius/isabelle:latest
---> da948b0dd494
Step 2/9 : SHELL ["/bin/bash", "-c"]
---> Using cache
---> 64f897ae98ea
Step 3/9 : RUN apt-get update && apt-get install --yes build-essential && apt-get install --yes openjdk-8-jdk && apt-get install --yes xterm && apt-get install --yes iputils-ping && apt-get install --yes vim && apt-get install --yes net-tools && apt-get -y install xauth && apt-get clean
---> Running in 9ec12ecb98e8
Reading package lists...
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
The command '/bin/bash -c apt-get update && apt-get install --yes build-essential && apt-get install --yes openjdk-8-jdk && apt-get install --yes xterm && apt-get install --yes iputils-ping && apt-get install --yes vim && apt-get install --yes net-tools && apt-get -y install xauth && apt-get clean' returned a non-zero code: 100
I expect to be able to build the extended image from the existing one, with two users defined and all packages installed. I can get by with a single user as well if have to.
The parent image markarius/isabelle switched user to isabelle, you gotta switch it back to root to run apt-get with additional line USER root before that line in your docker file. There's no need to use sudo in docker images since by default you already have root access.

M1 Mac Docker Issues with apt-get update

I'm having an issue adding Microsoft package list to apt-get in my Dockerfile running on my M1 macbook pro. I was able to run this on my old windows laptop, but now on my mac, I get the Unable to locate package msodbcsql17 error. Just as a sanity check I also tried installing mssql-tools first, but that package was not found as well, so it seems like the entire process of adding these packages to apt-get is failing. Is there something I can do in order to get this to work for both m1 mac and machines using classic architecture?
FROM python:3.7
WORKDIR /app/repo
RUN mkdir /app/docker_volume
RUN apt-get update \
&& apt-get install unixodbc -y \
&& apt-get install unixodbc-dev -y \
&& apt-get install freetds-dev -y \
&& apt-get install freetds-bin -y \
&& apt-get install tdsodbc -y \
&& apt-get install --reinstall build-essential -y
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17
RUN ACCEPT_EULA=Y apt-get install -y mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
RUN /bin/bash -c "source ~/.bashrc"```
The package list grabbed by the curl command references the architecture of your system, and as there are no mssql-tools or msodbcsql17 packages for arm64 architecture at the moment, I was getting the unable to locate error. Current solution is changing the first line of the Dockerfile to specify the platform with FROM --platform=linux/amd64 python:3.7

Install libmysqlclient-dev along with npm in dockers

I have an error when trying to install the libmysqlclient-dev package together with npm for some reason when installing libmysqlclient-dev it removes npm
Step 10/26 : RUN apt-get install -y libmysqlclient-dev
---> Running in beae8aee9cd4
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
gyp javascript-common libjs-async libjs-inherits libjs-jquery
libjs-node-uuid libjs-underscore libuv1-dev node-abbrev node-ansi
node-ansi-color-table node-archy node-async node-balanced-match
node-block-stream node-brace-expansion node-builtin-modules
node-combined-stream node-concat-map node-cookie-jar node-delayed-stream
node-forever-agent node-form-data node-fs.realpath node-fstream
node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs
node-hosted-git-info node-inflight node-inherits node-ini
node-is-builtin-module node-isexe node-json-stringify-safe node-lockfile
node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream
node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once
node-osenv node-path-is-absolute node-pseudomap node-qs node-read
node-read-package-json node-request node-retry node-rimraf node-semver
node-sha node-slide node-spdx-correct node-spdx-expression-parse
node-spdx-license-ids node-tar node-tunnel-agent node-underscore
node-validate-npm-package-license node-which node-wrappy node-yallist
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libssl-dev
Suggested packages:
libssl-doc
The following packages will be REMOVED:
libssl1.0-dev node-gyp nodejs-dev npm
The following NEW packages will be installed:
libmysqlclient-dev libssl-dev
0 upgraded, 2 newly installed, 4 to remove and 133 not upgraded.
Need to get 2,583 kB of archives.
After this operation, 5,175 kB disk space will be freed.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl-dev amd64 1.1.1-1ubuntu2.1~18.04.9 [1,566 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmysqlclient-dev amd64 5.7.34-0ubuntu0.18.04.1 [1,016 kB]
dpkg-preconfigure: unable to re-open stdin:
Fetched 2,583 kB in 2s (1,412 kB/s)
(Reading database ... 25174 files and directories currently installed.)
Removing npm (3.5.2-0ubuntu4) ...
Removing node-gyp (3.6.2-1ubuntu1) ...
Removing nodejs-dev (8.10.0~dfsg-2ubuntu0.4) ...
Removing libssl1.0-dev:amd64 (1.0.2n-1ubuntu5.6) ...
That gives me the following error:
Step 14/26 : RUN npm install -g npm#4.1.1
---> Running in 18f70438b2ae
/bin/sh: 1: npm: not found
ERROR: Service 'webapp' failed to build: The command '/bin/sh -c npm install -g npm#4.1.1' returned a non-zero code: 127
This is my Dockerfile:
RUN apt-get update
RUN apt-get install -y tzdata
RUN apt-get install -y libfontconfig1
RUN apt-get install -y libxrender1
RUN apt-get install -y nodejs
RUN apt-get install -y npm
RUN apt-get install -y yarn
RUN apt-get install -y mysql-client
RUN apt-get install -y libmysqlclient-dev
RUN apt-get install -y shared-mime-info
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN npm install -g npm#4.1.1
RUN npm install -g yarn
I am working on ruby on rails and I need the libmysqlclient-dev package for the mysql2 gem
How can i fix this?
You will want to read the Dockerfile best practices for the RUN instruction from the Docker docs. Each line in a Dockerfile is an image layer and the state after a RUN instruction is executed command is not always persisted on the next layer.
So the apt-get install -y npm won't affect the build when you run npm install -g ... so you received the error: npm command not found.
Please read the guide and attempt to use this single RUN instruction instead.
RUN apt-get update \
&& apt-get install -y tzdata \
&& apt-get install -y libfontconfig1 \
&& apt-get install -y libxrender1 \
&& apt-get install -y nodejs \
&& apt-get install -y npm \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y libmysqlclient-dev \
&& apt-get install -y shared-mime-info \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& npm install -g npm#4.1.1 \
npm install -g yarn
using a new node that comes with npm helped for me:
apt-get -qq update && \
apt-get -qq --no-install-recommends install curl && \
curl -sL https://deb.nodesource.com/setup_17.x | bash - && \
apt-get -qq --no-install-recommends install \
openssl \
nodejs \
linux-headers-generic \
tzdata \
libmysqlclient-dev
In Ubuntu 18.04 (bionic) there is a conflict between libmysqlclient-dev and the npm packages, one requires libssl1.0-dev and the other libssl-dev:
The following packages have unmet dependencies:
libssl-dev : Conflicts: libssl1.0-dev but 1.0.2n-1ubuntu5.9 needs to be installed.
libssl1.0-dev : Conflicts: libssl-dev but must install 1.1.1-1ubuntu2.1~18.04.17
It's not related to the way you were using docker, but to a conflict in the packages themselves. The easiest workaround is to install node from upstream:
RUN curl -sL https://deb.nodesource.com/setup_17.x | bash - && apt-get install -y nodejs

Dockerfile can't open ODBC driver 17 and fails during running the python script

I have create in docker 2 contains 1 to run the MSSQL server and the other a python container with the code to read data from an .xlsx file and inserting it into SQL server.
My Dockerfile has the below code :
FROM python:3.6-alpine
RUN apk update
RUN apk add gcc libc-dev g++ libffi-dev libxml2 unixodbc-dev mariadb-dev postgresql-dev
FROM continuumio/miniconda3
ADD test.py /
RUN apt-get update -y \
&& apt install python3 -y \
&& apt install python3-pip -y \
&& apt install python3-venv -y \
&& python3 -m venv venv
RUN apt-get -y install curl
**#Install FreeTDS and dependencies for PyODBC**
RUN apt-get update && apt-get install -y tdsodbc unixodbc-dev \
&& apt install unixodbc-bin -y \
&& apt-get clean -y
RUN apt-get update
RUN apt-get install -y tdsodbc unixodbc-dev
RUN apt install unixodbc-bin -y
RUN apt-get clean -y
RUN pip install pandas
RUN pip install pyodbc
RUN pip install DateTime
RUN pip install multiprocess
RUN pip install threaded
CMD [ "python", "./test.py" ]
It compiles successfully but fails every time i run the container with the below error :
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
I have been trying this for days but found no resolution.
Believe I need to install ODBC driver 17, if so how do I add it to my Dockerfile?

Docker installation debian openjdk-7-jre

I've been trying to install openjdk-7-jre in a docker image. But when I tried to install it I got the following error:
E: Failed to fetch http://security.debian.org/pool/updates/main/o/openjdk-7/openjdk-7-jre-headless_7u111-2.6.7-2~deb8u1_amd64.deb Connection failed [IP: 200.17.202.197 80]
I've been spending a lot of hours trying this. For More details, the instruction in the Dockerfile is:
RUN apt-get update -qq && apt-get install -y -f xvfb wget
RUN sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list && \
apt-get update -qq && \
apt-get install --fix-missing -y -f openjdk-7-jre
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
dpkg --unpack google-chrome-stable_current_amd64.deb && \
apt-get install -f -y && \
apt-get clean && \
apt-get update && \
rm google-chrome-stable_current_amd64.deb
RUN npm install -g protractor mocha jasmine cucumber && \
webdriver-manager update && \
apt-get update
What am I doing wrong?
This is because you are getting an error in the second RUN command, apt-get update -qq. The error is getting buried because of -qq flag (which will quite the error messages. Try without -qq to diagnoise the error)
You can try using below Dockerfile for installing openjdk-7-jre.
FROM ubuntu
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:openjdk-r/ppa
RUN apt-get update
RUN apt-get install --fix-missing -y -f openjdk-7-jre
just added FROM debian:jessie to your dockerfile and successfully built the image. Your problem is your internet connection, Use VPN or Proxy servers to build the image.

Resources