Using Docker, how to change bash version inside Dockefile? - bash

When I login into a running container, and issue a bash --version command I am seeing the following
root#sb-core-repo-7988897977-rdtkb:/myapp# bash --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Since, this GNU bash version 5.0.3 has a vulnerability, I would like to update the bash to 5.1.2 apparently, the vulnerability has been fixed in that release. as per vulnerability
How and what can I update in the Dockerfile to update the bash version?
My Dockerfile is like this:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /myapp
EXPOSE 80
## Installing tools for dotnet core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 As pre-build
RUN apt-get update && apt-get install -y openjdk-11-jre
ENV PATH="$PATH:/root/.dotnet/tools"
FROM pre-build AS build
WORKDIR /src
COPY ["PhantomService.Application/PhantomService.Application.csproj", "PhantomService.Application/"]
COPY ["PhantomService.RestApi/NuGet.Config", "PhantomService.RestApi/"]
RUN dotnet restore "PhantomService.RestApi/PhantomService.RestApi.csproj" --configfile "PhantomService.RestApi/NuGet.Config"
## Build and Test
RUN dotnet build "PhantomService.RestApi/PhantomService.RestApi.csproj" -c Release -o /myapp
FROM build AS publish
RUN dotnet publish "PhantomService.RestApi/PhantomService.RestApi.csproj" -c Release -o /myapp
FROM base AS final
WORKDIR /myapp
COPY --from=publish /myapp .
ENTRYPOINT ["dotnet", "PhantomService.RestApi.dll"]
appreciate all the help and advice

Related

How to Install devtoolset 8 in RHEL 8 image

Please help me to install dev toolset-8 in rhel 8 image.
i have pulled the base image as below . I want to install devtoolset-8. is there any other way please let me know.
sudo docker pull registry.access.redhat.com/ubi8/ubi:8.2
According to that article, you can check if you have access to Red Hat Software Collections (RHSCL) by running the following command by the root user:
$ su -
# subscription-manager repos --list | egrep rhscl
If you have, enable necessary software repo and then install devtoolset:
# subscription-manager repos --enable rhel-7-server-optional-rpms
# yum install devtoolset-8
The other answer seems to be for RHEL 7.
On the RedHat site
Chrisian Labisch answered this with:
RHEL 8 doesn't work with Software Collections, RHEL 8 uses modules instead.
sudo dnf module list
In RHEL 8 you find the developer tools in the CodeReady Builder repository. :)
sudo subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms
But even that seems to be unneeded because the system compiler version for RHEL is already GCC 8, so you would normally only need devtoolset-9 or up for it, if I understood the purpose correctly.
Additionally this blog post outlines the differences between the old SCL toolsets and the new AppStreams concept.
devtoolset is called gcc-toolset in RHEL8.
The following commands worked for me:
microdnf install -y gcc-toolset-12
scl enable gcc-toolset-12 bash
gcc --version
# gcc (GCC) 12.1.1 20220628 (Red Hat 12.1.1-3)

Docker Oracle Instant Client

I have been trying for 4 days to:
Deploy Oracle Instant Client with Docker. I can give you the Dockerfile but it is 96 lines
To use Oracle Instant Client on my Linux Ubuntu latest.
In the end I arrive at the same two issues.
When installing OCI 8 with the command:
Docker:
RUN echo 'instantclient, / usr / local / instantclient' | pecl install
oci8
Ubuntu:
echo "instantclient, / opt / oracle / instantclient_12_2" | sudo pecl
install oci8
I get the error:
make: *** [Makefile: 194: oci8.lo] Error 1
ERROR: `make 'failed
Could not find a solution.
Make is correctly installed in both cases:
GNU Make 4.2.1 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2016
Free Software Foundation, Inc. GPLv3 + license: GNU GPL version 3 or
later http://gnu.org/licenses/gpl.html This is free software: you
are free to change and redistribute it. There is NO WARRANTY, to the
extent permitted by law.
Do you have an idea ? It blocks me for the rest of my work.
BR,
Nicolas.
EDIT :
I try this :
pear download pecl/oci8
tar xvzf oci8-3.0.0.tgz
phpize
./configure --with-oci8=instantclient,/opt/oracle/instantclient_12_2/
make
Same issue :
make: *** [Makefile:194: oci8.lo] Error 1
I'm going crazy...
If you follow the instructions from Oracle's Github Repo for Docker you should be able to build your own instantclient.
https://github.com/oracle/docker-images/tree/master/OracleInstantClient
Another option will be to just make use of an existing image from their container-registry.
docker pull container-registry.oracle.com/database/instantclient:latest
Best of luck!
I did it this way:
RUN echo 'instantclient,/opt/oracle/instantclient/lib' | pecl install oci8

When trying to build docker image, I get ""gcc": executable file not found in $PATH"

I have gcc on windows.
C:\Users\jkrov>gcc --version
gcc (MinGW.org GCC-8.2.0-5) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
My docker file:
FROM golang:alpine
RUN mkdir /app
WORKDIR /app
ADD . /app
RUN go build -o main .
EXPOSE 8080
CMD [ "app/main" ]
When I try to build image I get error:
exec: "gcc": executable file not found in $PATH
I encountered the same problem when building a go app using an alpine image. Installing gcc fixed the problem. Here is how your Dockerfile should look like:
FROM golang:alpine
RUN apk add build-base
RUN mkdir /app
WORKDIR /app
ADD . /app
RUN go build -o main .
EXPOSE 8080
CMD [ "app/main" ]
Add the gcc tools fixed the problem.
RUN apk add build-base
Also you can the this:
RUN apk --no-cache add make git gcc libtool musl-dev ca-certificates dumb-init

Build Golang Application with librdkafka in a Debian Docker Image?

With Alpine, Alpine fully supports recent versions of librdkafka, I can just do apk add in my Dockerfile, and the following works:
FROM golang:1.13-alpine3.10 as builder
WORKDIR /app
COPY go.mod go.sum ./
COPY src ./src/
RUN set -eux; \
apk add --no-cache gcc git libc-dev librdkafka-dev; \
go build -o ./ ./...
Now, for a particular project, I need to make Debian friendly binaries, that will run on Debian/Ubuntu servers.
The problem is that:
The official Debian repositories only support really old 0.11.x versions of librdkafka. Even for stretch and buster including backports repos. They don't have more recent versions.
The official Confluent repositories only support librdkafka on Debian 8 (jessie). They don't support librdkafka at all on Debian 9 (stretch) or 10 (buster) due to a libssl version incompatibility.
The official golang images only support Debian 9 (stretch) and 10 (buster). They don't support Debian 8 (Jessie).
My options:
Use a dev branch of the Golang Kafka client that doesn't need librdkafka installed at the system level. This would be amazing if it was stable and recommended.
Manually install/build librdkafka on Debian 9/10.
Get a Debian 8 golang image?
Can I do Debian target builds from Alpine? I suspect no, but it's worth asking.
What is the recommended solution?
Here is the solution which worked for me. I had to download it from source and it gives the latest version
Sample Dockerfile looks like this:
FROM golang:1.12.9-alpine AS build-stage
LABEL app="application_name"
ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin
# Because of https://github.com/docker/docker/issues/14914
# required by go get
RUN apk add --update --no-cache alpine-sdk bash python ca-certificates \
libressl \
tar \
git openssh openssl yajl-dev zlib-dev cyrus-sasl-dev openssl-dev coreutils
WORKDIR /src/application_name
RUN git clone https://github.com/edenhill/librdkafka.git
WORKDIR /src/application_name/librdkafka
RUN /src/application_name/librdkafka/configure --prefix /usr
RUN make
RUN make install
WORKDIR /src/application_name
COPY . .
# build the application
RUN GOOS=linux go build -a -o image-name .

How to compile an OpenJDK 7 debug build on Ubuntu 11.10

Where can I find a simple set of instructions to compile an OpenJDK 7 debug build on Ubuntu 11.10 (Oneiric)? A debug build would make more JVM options available for troubleshooting purposes; for example, WizardMode. The developers' guide and build README have a lot of noise and are hard to follow.
Install relevant packages:
sudo apt-get install ant build-essential openjdk-6-jdk
sudo apt-get build-dep openjdk-6-jdk
Find the master OpenJDK Mercurial repository you want to start from. These instructions will use jdk7u2.
Command examples contain settings to allow Internet access through a proxy server; remove them if they are unnecessary for you.
Clone the Mercurial top-level forest repository:
$ mkdir jdk7u2
$ cd jdk7u2
$ hg --config http_proxy.host=proxy:1234 clone http://hg.openjdk.java.net/jdk7u/jdk7u2 forest
$ cd forest
$ sh ./get_source.sh
The build will fail while compiling the sound libraries. As suggested here, use the following to patch the appropriate Makefile:
$ echo -e "--- old/jdk/make/javax/sound/jsoundalsa/Makefile 2012-01-28 12:00:00.000000000 -0500\n+++ new/jdk/make/javax/sound/jsoundalsa/Makefile 2012-01-28 12:00:00.000000000 -0500\n## -65,7 +65,7 ##\n \t\$(MIDIFILES_export) \\\\\n \t\$(PORTFILES_export)\n\n-LDFLAGS += -lasound\n+EXTRA_LIBS += -lasound\n \n CPPFLAGS += \\\\\n \t-DUSE_DAUDIO=TRUE \\\\" | patch -p1
Compile:
$ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=1234 -Dhttps.proxyHost=proxy -Dhttps.proxyPort=1234"
$ . jdk/make/jdk_generic_profile.sh
$ make ALLOW_DOWNLOADS=true fastdebug_build
The compile will take a while.
Verify the build:
$ build/linux-amd64-fastdebug/j2sdk-image/bin/java -version
openjdk version "1.7.0-internal-fastdebug"
OpenJDK Runtime Environment (build 1.7.0-internal-fastdebug-user_2012_01_28_13_25-b00)
OpenJDK 64-Bit Server VM (build 22.0-b10-fastdebug, mixed mode)
$ build/linux-amd64-fastdebug/j2sdk-image/bin/java -XX:+AggressiveOpts -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -XX:+PrintFlagsWithComments -version
If you have problems along the way, begin by reading The OpenJDK Developers' Guide and the OpenJDK Build README.

Resources