Why am I getting Unable to correct problems, you have held broken packages - docker

Trying to run Dockerfile and it fails at installing npm.
ERROR:
Unable to correct problems, you have held broken packages.
The command '/bin/sh -c apt-get install -y npm' returned a non-zero code: 100
Dockerfile:
FROM ubuntu:14.04
MAINTAINER Giacomo Vacca "giacomo.vacca#gmail.com"
ENV REFRESHED_AT 2015-01-19
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get autoremove
RUN npm -v
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install --yes curl
RUN curl --silent --location http://deb.nodesource.com/setup_0.10 | sudo bash -
RUN apt-get install -y nodejs
RUN apt-get install --yes build-essential
RUN rm /usr/bin/node
# needs this to find the nodejs exec
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN apt-get install -y npm <--- FAIL
RUN /usr/bin/npm install socket.io#0.9.14
EXPOSE 8080
ENTRYPOINT ["/usr/bin/node", "/root/server.js"]

You don't need to install npm from the ubuntu distribution with:
RUN apt-get install -y npm
because it's already installed by the nodejs package from nodesource. You can check it with:
dpkg -L nodejs | grep "/usr/bin/npm"

Related

mdatp install in Docker

I am trying to install windows defender in a docker container.
But Facing the following error while Docker Build.
System has not been booted with systemd as init system (PID 1). Can't
operate. Failed to connect to bus: Host is down
Docker File :
FROM openjdk:11
RUN apt-get -y update
RUN apt-get -y install curl
RUN curl -o microsoft.list https://packages.microsoft.com/config/debian/10/prod.list
RUN mv ./microsoft.list /etc/apt/sources.list.d/microsoft-prod.list
RUN apt-get install -y gpg
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN apt-get install apt-transport-https
RUN apt-get -y update
RUN apt-get install -y systemd
RUN apt-get install -y mdatp

Can't access port 8080, 50000 and 8888 while installing jenkins and jupyter

I am new to dokers. I need jenkins and jupyter notebook in the same container. I have written the following Dockerfile but I can't access localhost:8888 or 8080 or 50000 when I run this image. However, these ports work very well when I run the official jenkins image. So, I don't know where I am making the mistake in my Dockerfile.
# using ubuntu as base image
FROM ubuntu:20.04
# installing python version 3.8
RUN apt-get update -y \
&& apt-get install -y apt-utils \
&& apt-get install python3.8 -y
# installing jupyter notebook
RUN apt-get install jupyter -y
EXPOSE 8888
# installing jenkins
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install dialog apt-utils -y
RUN apt-get update && apt-get install -y gnupg2
RUN apt-get install -y wget
RUN wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | apt-key add -
RUN sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
RUN apt-get update
RUN apt-get install jenkins -y
EXPOSE 50000 8080
# removing unnecessary files
RUN rm -rf /var/lib/apt/lists/*
COPY sample.py .
LABEL maintainer=Ammar
CMD ["bash"]

Docker, sbt - cannot install sbt with centos docker image

I would like to have sbt in my docker image. I created a Dockerfile base on centos:centos8 image:
FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 0.13.18
RUN yum install -y epel-release
RUN yum update -y && yum install -y wget
RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar
WORKDIR /root
EXPOSE 8080
RUN sbt compile
CMD sbt run
And also I need to have sbt installed here, but when I ran this script I got an error:
Step 10/11 : RUN sbt compile
---> Running in 0aadcd774ba0
/bin/sh: sbt: command not found
I cannot understand why sbt could not been found. Is it a good way to achieve what I need or I should try other one? But I need to do it with centos
EDIT:
Finally it works after help from answer below. Working script looks like:
FROM centos:centos8
ENV SBT_VERSION 0.13.17
RUN yum install -y java-11-openjdk && \
yum install -y epel-release && \
yum update -y && yum install -y wget && \
wget http://dl.bintray.com/sbt/rpm/sbt-$SBT_VERSION.rpm && \
yum install -y sbt-$SBT_VERSION.rpm
WORKDIR /root
EXPOSE 8080
RUN sbt compile
CMD sbt run
You would need to install sbt inside your Dockerfile. Here is an example:
FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 0.13.17
RUN yum install -y epel-release
RUN yum update -y && yum install -y wget
# INSTALL JAVA
RUN yum install -y java-11-openjdk
# INSTALL SBT
RUN wget http://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm
RUN yum install -y sbt-${SBT_VERSION}.rpm
RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar
WORKDIR /root
EXPOSE 8080
RUN sbt compile
CMD sbt run
Note: I did not see the version you had in your env variable (0.13.18) so I changed it to 0.13.17.
I ran into an issue where bintray.com was returning 403 randomly. I'm assuming it might be some kind of traffic throttle. Added the rpm file locally.
COPY sbt-0.13.18.rpm /
RUN yum install -y sbt-0.13.18.rpm

Dockerfile to create an image to be used as an container agent in jenkins

I am trying to use a node agent container in Jenkins to run npm instructions on it. So that, I am creating a Dockerfile to get a valid image with ssh and nodejs. The executor runs fine, but when I use npm it says that it doesn't know the command.
The same problem happens when (after building the dockerfile) I do docker exec -it af5451297d85 bash and after that, inside the container, I try to do npm --v (for example).
# This Dockerfile is used to build an image containing an node jenkins agent
FROM node:9.0
MAINTAINER Estefania Castro <estefania.castro#luceit.es>
# Upgrade and Install packages
RUN apt-get update && apt-get -y upgrade && apt-get install -y git openssh-server
# Install NGINX to test.
RUN apt-get install nginx -y
# Prepare container for ssh
RUN mkdir /var/run/sshd && adduser --quiet jenkins && echo "jenkins:jenkins" | chpasswd
RUN npm install
ENV CI=true
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
I would like to run npm instructions like npm install, npm publish, ... to manage my project in a jenkinsfile. Could anyone help?
Thanks
I have already solved the problem (after two weeks haha).
FROM jenkins/ssh-slave
# Install selected extensions and other stuff
RUN apt-get update && apt-get -y --no-install-recommends install && apt-get clean
RUN apt-get install -y curl
# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs && apt-get install -y nginx

Install kotlin in ubuntu image getting error

I am getting an error while installing kotlin in ubuntu image.
FROM ubuntu:16.04
RUN apt-get update
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get -qq -y install curl
RUN apt-get install -y unzip
RUN apt-get install -y zip
RUN curl -s https://get.sdkman.io | bash
RUN chmod a+x "$HOME/.sdkman/bin/sdkman-init.sh"
RUN source "$HOME/.sdkman/bin/sdkman-init.sh"
RUN sdk install kotlin
Getting error
Step 10/35 : RUN sdk install kotlin
---> Running in 9282af532681
/bin/sh: sdk: command not found
ERROR: Service 'myproject' failed to build: The command '/bin/sh -c sdk install kotlin' returned a non-zero code: 127
FROM ubuntu:16.04
RUN apt-get update
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN apt-get -qq -y install curl
RUN apt-get install -y unzip
RUN apt-get install -y zip
RUN curl -s https://get.sdkman.io | bash
RUN chmod a+x "$HOME/.sdkman/bin/sdkman-init.sh"
RUN source "$HOME/.sdkman/bin/sdkman-init.sh" && sdk install kotlin
Each RUN have their own "session". So RUN sdk install kotlin will not know about previous source command.
Multiple RUN is not optimal: each RUN will create a layer.
Looks like you want to create docker image with Kotlin JVM. Then you need standard openjdk:8-jdk (Or what version you want) and then just put there your jar file.

Resources