Problems running programs installed in docker platform containers - linux

I rented a docker platform container and tried to run it using a Dockerfile with the following code:
FROM debian:buster-slim
RUN cd /tmp
RUN apt update
RUN apt full-upgrade -y
RUN apt install wget libglib2.0-0 netbase -y
RUN wget https://(sample download link for the program to be installed).deb
RUN dpkg -i /tmp/(example program).deb
CMD /opt/my program/my program
However in running pods I get log information like this:
This Program requires root privileges
When I try to install it in Workdir root with example docker file:
FROM ubuntu:focal
WORKDIR /root
RUN cd /root
RUN apt update
RUN apt full-upgrade -y
RUN apt install wget libglib2.0-0 netbase -y
RUN wget https://(sample download link for the program to be installed).deb
RUN dpkg -i /tmp/(example program).deb
RUN chmod +x /root/my program
CMD /root/My Programs
The result I got was:
/bin/bash My program Permisson denied
tried to change CMD to add to:
CMD["bash", "/root/myprogram"]
The result is still
/bash My program Permisson denied
I wrapped the above code using dockerfile.

Related

Docker - No rule to make target `hiredis'

I have been scratching my head since past 2 days for this issue. I am using amazon linux image and trying to install redis through a Dockerfile, but this doesn't work.
RUN yum install -y java-17-amazon-corretto.x86_64
RUN yum install -y tar
RUN yum install -y wget
RUN yum -y update
RUN yum -y install gcc make
RUN wget http://download.redis.io/redis-stable.tar.gz
RUN tar xvzf redis-stable.tar.gz
RUN cd redis-stable/deps
make hiredis jemalloc linenoise lua geohash-int
cd ..
make install
When I follow the docs, it says run make and make install from the root of the install directory.
RUN cd redis-stable
RUN make
RUN make install

Unable to install package using docker : kpt not found or ambiguous repo/dir#version specify '.git' in argument

I am using below script and it giving me an error #/bin/sh: 1: kpt: not found
FROM nginx
RUN apt update
RUN apt -y install git
RUN apt -y install curl
# install kpt package
RUN mkdir -p ~/bin
RUN curl -L https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.1/kpt_linux_amd64 --output ~/bin/kpt && chmod u+x ~/bin/kpt
RUN export PATH=${HOME}/bin:${PATH}
RUN SRC_REPO=https://github.com/kubeflow/manifests
RUN kpt pkg get $SRC_REPO/tf-training#v1.1.0 tf-training
But if I create the image using
FROM nginx
RUN apt update
RUN apt -y install git
RUN apt -y install curl
and perform
docker exec -it container_name bash
and manually do the task then I am able to install kpt package. Sharing below the screenshot of the process
The error changes if I provide the full path to /bin/kpt
Error: ambiguous repo/dir#version specify '.git' in argument
FROM nginx
RUN apt update
RUN apt -y install git
RUN apt -y install curl
RUN mkdir -p ~/bin
RUN curl -L https://github.com/GoogleContainerTools/kpt/releases/download/v1.0.0-beta.1/kpt_linux_amd64 --output ~/bin/kpt && chmod u+x ~/bin/kpt
RUN export PATH=${HOME}/bin:${PATH}
# Below line of code is to ensure that kpt is installed and working fine
RUN ~/bin/kpt pkg get https://github.com/ajinkya101/kpt-demo-repo.git/Packages/Nginx
RUN SRC_REPO=https://github.com/kubeflow/manifests
RUN ~/bin/kpt pkg get $SRC_REPO/tf-training#v1.1.0 tf-training
What is happening when I am using docker and not able to install it?
First, make sure SRC_REPO is declared as a Dockerfile environment variable
ENV SRC_REPO=https://github.com/kubeflow/manifests.git
^^^ ^^^^
And make sure the URL ends with .git.
As mentioned in kpt get:
In most cases the .git suffix should be specified to delimit the REPO_URI from the PKG_PATH, but this is not required for widely recognized repo prefixes.
Second, to be sure, specify the full path of kpt, without ~ or ${HOME}.
/root/bin/kpt
For testing, add a RUN id -a && pwd to be sure who and where you are when using the nginx image.

How to add user and a group in Docker Container running Macosx

I have a Docker container running "FROM arm64v8/oraclelinux:8" , I am running this on a Mac m1 mini using tightvnc.
I want to add a user called "suiteuser" (uid 42065) and in a group called "cvsgroup" (gid 513), inside my docker container, So that when I run the container it starts under my user directly.
Here is my entire Dockerfile-
FROM arm64v8/oraclelinux:8
# Setup basic environment stuff
ENV container docker
ENV LANG en_US.UTF-8
ENV TZ EST
ENV DEBIAN_FRONTEND=noninteractive
# Base image stuff
#RUN yum install -y zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel vim yum-utils sssd sssd-tools krb5-libs krb5-workstation.x86_64
# CCSMP dependent
RUN yum install -y wget
RUN yum install -y openssl-libs-1.1.1g-15.el8_3.aarch64
RUN yum install -y krb5-workstation krb5-libs krb5-devel
RUN yum install -y glibc-devel glibc-common
RUN yum install -y make gcc java-1.8.0-openjdk-devel tar perl maven svn openssl-devel gcc
RUN yum install -y gdb
RUN yum install -y openldap* openldap-clients nss-pam-ldapd
RUN yum install -y zlib-devel bzip2 bzip2-devel vim yum-utils sssd sssd-tools
# Minor changes to image to get ccsmp to build
RUN ln -s /usr/lib/jvm/java-1.8.0-openjdk /usr/lib/jvm/default-jvm
RUN cp /usr/include/linux/stddef.h /usr/include/stddef.h
# Install ant 1.10.12
RUN wget https://mirror.its.dal.ca/apache//ant/binaries/apache-ant-1.10.12-bin.zip
RUN unzip apache-ant-1.10.12-bin.zip && mv apache-ant-1.10.12/ /opt/ant
ENV JAVA_HOME /usr
ENV ANT_HOME="/usr/bin/ant"
ENV PATH="/usr/bin/ant:$PATH"
CMD /bin/bash
could anyone please suggest any ideas on how to do this.
Note 1. I know its not advisable to do this directly in the container as, every time you want to make any changes you would have to rebuild it, but this time i want to do this.
To create the group:
RUN groupadd -g 513 cvsgroup
To create the user, as a member of that group:
RUN useradd -G cvsgroup -m -u 42065 suiteuser
And toward the end of Dockerfile, you can set the user:
USER suiteuser
There may be more to do here, though, depending on your application. For example, you may need to chown some of the contents to be owned by suiteuser.

Docker run only works after build

I can build and run a container with
docker build -t hopperweb:v5-full -f Dockerfile . &&
docker run -p 127.0.0.1:3000:8080 --rm -ti hopperweb:v5-full
However when I run the container I get this error: standard_init_linux.go:211: exec user process caused "exec format error"
docker run -p 127.0.0.1:3000:8080 --rm -ti hopperweb:v5-full
Why is it working when it's run after &&??
I can run the image with bash: docker run -p 127.0.0.1:3000:8080 --rm -ti hopperweb:v5-full bash without issue.
This is my DockerFile
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install --yes curl
RUN apt-get install --yes sudo ## maybe not necessary, but helpful
RUN apt-get install --yes gnupg
RUN apt-get install --yes git ## not necessary, but helpful
RUN apt-get install --yes vim ## not necessary, but helpful
## INSTALL NPM
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo 'deb https://dl.yarnpkg.com/debian/ stable main' | sudo tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get install --yes yarn
RUN apt-get install --yes npm
## COPY IN APP FILES
RUN mkdir /app
COPY hopperweb/ /app/hopperweb/
RUN chmod +x /app/hopperweb/start.sh
RUN /app/hopperweb/start.sh
The contents of start.sh:
#!/bin/bash
cd /app/hopperweb/
yarn start
In your first command, the docker run is never executed, as the last command (start.sh) is run during your build and it will never terminate. So you were still running docker build.
Change the following line
RUN /app/hopperweb/start.sh
to
CMD /app/hopperweb/start.sh
Do not confuse RUN with CMD. RUN actually runs a command and commits the result; CMD does not execute anything at build time, but specifies the intended command for the image.
See: https://docs.docker.com/engine/reference/builder/#cmd

Error using Oracle Instant Client Docker image

our app is nodejs based and needs to query Oracle DB, so we install NPM oracledb package. So our Docker image is based on oracle instant client, the Docker file looks like following:
FROM frolvlad/alpine-glibc
RUN apk update && apk add libaio
COPY instantclient_12_1.zip ./
RUN unzip instantclient_12_1.zip
RUN mv instantclient_12_1/ /usr/lib/
RUN rm instantclient_12_1.zip
RUN ln /usr/lib/instantclient_12_1/libclntsh.so.12.1 /usr/lib/libclntsh.so
RUN ln /usr/lib/instantclient_12_1/libocci.so.12.1 /usr/lib/libocci.so
RUN ln /usr/lib/instantclient_12_1/libociei.so /usr/lib/libociei.so
RUN ln /usr/lib/instantclient_12_1/libnnz12.so /usr/lib/libnnz12.so
ENV ORACLE_BASE /usr/lib/instantclient_12_1
ENV LD_LIBRARY_PATH /usr/lib/instantclient_12_1
ENV TNS_ADMIN /usr/lib/instantclient_12_1
ENV ORACLE_HOME /usr/lib/instantclient_12_1
RUN apk add nodejs npm
RUN mkdir -p /var/app
WORKDIR /var/app
ADD package.json /var/app
COPY . /var/app
CMD ["npm","start"]
But when our app starts using 'oracledb' NPM package, it got following error:
init() error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "Error loading shared library libnsl.so.1: No such file or directory (needed by /usr/lib/libclntsh.so)". See https://oracle.github.io/odpi/doc/installation.html#linux for help Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
So Oracle client couldn't find libnsl.so.1 even thought it should come with glibc, and I can see that it is under:
'/usr/glibc-compat/lib'.
Any ideas how to fix this? Thanks in Advance.
# 1. Install dependencies
FROM node:8.15 as cache-package
COPY package.json /srv/src/package.json
WORKDIR /srv/src
RUN yarn install
# 2.
FROM node:8.15 as builder
# 1. Update everything on the box
RUN apt-get update && \
apt-get install sudo
#RUN apk --update add libaio bc net-tools
RUN sudo apt-get install unzip
RUN sudo apt-get install wget
RUN sudo apt-get install git
# 3. Install oracle client
RUN mkdir -p /opt/oracle
# 3.1 Get oracle client
WORKDIR /opt/oracle
RUN wget -O /opt/oracle/instantclient_18_3_linux.zip http://YOUR_URL_TO_DOWNLOAD_THE_CLIENT/instantclient_18_3_linux.zip
RUN sudo unzip /opt/oracle/instantclient_18_3_linux.zip
# 3.2 Configure oracle client to work with node
RUN sudo sh -c "echo /opt/oracle/instantclient_18_3_linux > /etc/ld.so.conf.d/oracle-instantclient.conf"
RUN sudo cat /etc/ld.so.conf.d/oracle-instantclient.conf
FROM node:8.15
RUN apt-get update && \
apt-get install sudo
RUN sudo apt-get install libaio1
RUN mkdir -p /srv/src/logs
RUN mkdir -p /srv/logs
RUN mkdir -p /opt/oracle
# 4. Set the working directory
# 5. Copy our project & install our dependencies
COPY --from=cache-package /srv/src /srv/src
COPY --from=builder /opt/oracle/instantclient_18_3_linux /opt/oracle/instantclient_18_3_linux
COPY --from=builder /etc/ld.so.conf.d/oracle-instantclient.conf /etc/ld.so.conf.d/oracle-instantclient.conf
RUN sudo ldconfig
RUN ln -sf /usr/share/zoneinfo/WET /etc/localtime
COPY . /srv/src
WORKDIR /srv/src
# 6. Start the app
CMD yarn start
Here is my dockerfile working fine, the srv/src is my directory where I have my code, just change for yours and it should work.
I have the same problem as you the past two days and now it works.

Resources