Docker error while creating container from application image over base image - windows

I have created a docker base image with my dependencies needed to run my application like Java, Python, VC++ and dotnet. On top of the base image, I am creating another docker image(application image) which copies my application(asp.net core Web API) so that it runs my API from browser. In this process when I am trying to create a container on top of my application image, I am getting the following error:
>docker run -d -p 4000:80 --name newappcontainer6 newappimage:6.0
eec248d2f4e9b3aac693382a293f950f0458d0d3ae49030fd558a95c0ee45adc
docker: Error response from daemon: container eec248d2f4e9b3aac693382a293f950f0458d0d3ae49030fd558a95c0ee45adc encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF6E59A9FAB: (caller: 00007FF6E595E19A) Exception(2) tid(398) 80070002 The system cannot find the file specified.
CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
Provider: 00000000-0000-0000-0000-000000000000].
I am not sure why this error is coming as my two images got created without any issues and if I checked in my images I see all my dependencies got installed properly and my app code copied inside the image.
Below are the two docker file contents which I am trying to run:
Base Image Dockerfile code:
FROM mcr.microsoft.com/windows/servercore:ltsc2019-amd64 AS installer
#install vc++
COPY VC_redist.x64.exe .
RUN c:\VC_redist.x64.exe /install /passive /norestart /log out.txt
#install Python
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
WORKDIR C:/temp/Python
#RUN New-Item C:/temp -ItemType Directory; New-Item C:/data -ItemType Directory;
ENV PYTHON_VERSION 3.10.4
ENV PYTHON_RELEASE 3.10.4
RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
Write-Host ('Downloading {0} ...' -f $url); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
\
Write-Host 'Installing ...'; \
# https://docs.python.org/3.10.4/using/windows.html#installing-without-ui
Start-Process python.exe -Wait \
-ArgumentList #( \
'/quiet', \
'InstallAllUsers=1', \
'TargetDir=C:\Python310', \
'PrependPath=1', \
'Shortcuts=0', \
'Include_doc=0', \
'Include_pip=0', \
'Include_test=0' \
); \
\
#the installer updated PATH, so we should refresh our local value
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
\
Write-Host 'Verifying install ...'; \
Write-Host ' python --version'; python --version; \
\
Write-Host 'Removing ...'; \
Remove-Item python.exe -Force; \
\
Write-Host 'Complete.'
# https://github.com/pypa/get-pip
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/d59197a3c169cef378a22428a3fa99d33e080a5d/get-pip.py
ENV PYTHON_GET_PIP_SHA256 421ac1d44c0cf9730a088e337867d974b91bdce4ea2636099275071878cc189e
RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -Uri $env:PYTHON_GET_PIP_URL -OutFile 'get-pip.py'; \
Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_GET_PIP_SHA256); \
if ((Get-FileHash 'get-pip.py' -Algorithm sha256).Hash -ne $env:PYTHON_GET_PIP_SHA256) { \
Write-Host 'FAILED!'; \
exit 1; \
}; \
\
Write-Host ('Installing pip ...'); \
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
; \
Remove-Item get-pip.py -Force; \
\
Write-Host 'Verifying pip install ...'; \
pip --version; \
\
Write-Host 'Complete.'
#install Java
MAINTAINER Zulu Enterprise Container Images <azul-zulu-images#microsoft.com>
RUN setx PACKAGE zulu-8-azure-jdk_8.58.0.13-8.0.312-win_x64.msi
RUN setx PACKAGE_DIR zulu-8/8u312
RUN setx /m JAVA_HOME "C:\temp\Zulu\zulu-8"
RUN setx /m JAVA_HOME "C:\temp\Zulu\zulu-8\bin"
RUN powershell -Command [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;(new-object System.Net.WebClient).DownloadFile('https://repos.azul.com/azure-only/zulu/packages/zulu-8/8u312/zulu-8-azure-jdk_8.58.0.13-8.0.312-win_x64.msi', 'C:\%PACKAGE%')
RUN msiexec /quiet /i C:\%PACKAGE%
RUN del C:\%PACKAGE%
RUN setx PACKAGE zulu-8-azure-jre_8.58.0.13-8.0.312-win_x64.msi
RUN setx PACKAGE_DIR zulu-8/8u312
RUN setx /m JAVA_HOME "C:\temp\zulu-8-jre"
RUN setx /m JAVA_HOME "C:\temp\zulu-8-jre\bin"
RUN powershell -Command [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;(new-object System.Net.WebClient).DownloadFile('https://repos.azul.com/azure-only/zulu/packages/zulu-8/8u312/zulu-8-azure-jre_8.58.0.13-8.0.312-win_x64.msi', 'C:\%PACKAGE%')
RUN msiexec /quiet /i C:\%PACKAGE%
RUN del C:\%PACKAGE%
RUN powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -UseBasicParsing -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1; ./dotnet-install.ps1 -InstallDir '/Program Files/dotnet' -Channel 6.0 -Runtime dotnet;
RUN Remove-Item -Force dotnet-install.ps1
#RUN setx /M PATH "%PATH%;C:\dotnet"
Image which I created for my Web API on top of the above base image:
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build-env
WORKDIR /Program Files/dotnet
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out
FROM newbaseimage:5.0 as runtime
#FROM mcr.microsoft.com/dotnet/aspnet:6.0 as runtime
#FROM newbaseimage:5.0 as installer
WORKDIR /Program Files/dotnet
COPY --from=build-env /app/out .
#COPY VC_redist.x64.exe .
#RUN VC_redist.x64.exe /install /passive /norestart /log out.txt
EXPOSE 80
ENTRYPOINT ["dotnet", "TestDesignStudioAPI.dll"]
#Environment variables to connect to Azure
ENV AZURE_CLIENT_ID=6baec3cf-e284-4db8-8576-5af4320f3849 \
AZURE_CLIENT_SECRET=LOm8Q~UM7fQDLFSsuvgnzv9wsTE2zFtsQAa4WbjQ \
AZURE_TENANT_ID=0fe67bdb-a749-4082-a35f-fa9f9579a348
Can anyone please suggest what I am doing wrong here?

Related

How to fix error while building glpk in windows

I am trying to build glpk to use in VS2019 but I got a problem that I cannot solve.
In the file Build_GLPK_with_VC9.bat I changed the directory to the folder which contains the file vcvars64.bat but when I compile I get the following error message:
[vcvarsall.bat] Environment initialized for: 'x64'
The system cannot find the path specified.
The system cannot find the path specified.
Somebody has an idea of how to solve this? I am executing the .bat while while admin mode but the error message persists.
EDIT
This is the original .bat file provided by glpk:
rem Build GLPK with Microsoft Visual Studio Express 2008 and
rem Windows Software Development Kit (SDK) for Windows Server 2008
rem NOTE: Make sure that HOME variable specifies correct path.
set HOME="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC"
call %HOME%\bin\vcvars64.bat
copy config_VC9 config.h
%HOME%\bin\nmake.exe /f Makefile_VC9 all
%HOME%\bin\nmake.exe /f Makefile_VC9 check
pause
And this is the same file with the path required:
rem Build GLPK with Microsoft Visual Studio Express 2008 and
rem Windows Software Development Kit (SDK) for Windows Server 2008
rem NOTE: Make sure that HOME variable specifies correct path.
set HOME="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC"
call %HOME%\Auxiliary\Build\vcvars64.bat
copy config_VC9 config.h
%HOME%\bin\nmake.exe /f Makefile_VC9 all
%HOME%\bin\nmake.exe /f Makefile_VC9 check
pause
The file Makefile_CV9 contains
# Build GLPK with Microsoft Visual Studio Express 2008 and
# Windows Software Development Kit (SDK) for Windows Server 2008
CFLAGS = /I. /DHAVE_CONFIG_H /nologo /W3 /MT /O2
OBJSET = \
..\src\glpapi01.obj \
..\src\glpapi02.obj \
..\src\glpapi03.obj \
..\src\glpapi04.obj \
..\src\glpapi05.obj \
..\src\glpapi06.obj \
..\src\glpapi07.obj \
..\src\glpapi08.obj \
..\src\glpapi09.obj \
..\src\glpapi10.obj \
..\src\glpapi11.obj \
..\src\glpapi12.obj \
..\src\glpapi13.obj \
..\src\glpapi14.obj \
..\src\glpapi15.obj \
..\src\glpapi16.obj \
..\src\glpapi17.obj \
..\src\glpapi18.obj \
..\src\glpapi19.obj \
..\src\glpavl.obj \
..\src\glpbfd.obj \
..\src\glpbfx.obj \
..\src\glpcpx.obj \
..\src\glpdmp.obj \
..\src\glpdmx.obj \
..\src\glpfhv.obj \
..\src\glpgmp.obj \
..\src\glphbm.obj \
..\src\glpini01.obj \
..\src\glpini02.obj \
..\src\glpios01.obj \
..\src\glpios02.obj \
..\src\glpios03.obj \
..\src\glpios04.obj \
..\src\glpios05.obj \
..\src\glpios06.obj \
..\src\glpios07.obj \
..\src\glpios08.obj \
..\src\glpios09.obj \
..\src\glpipm.obj \
..\src\glpipp01.obj \
..\src\glpipp02.obj \
..\src\glplib01.obj \
..\src\glplib02.obj \
..\src\glplib03.obj \
..\src\glplib04.obj \
..\src\glplib05.obj \
..\src\glplib06.obj \
..\src\glplib07.obj \
..\src\glplib08.obj \
..\src\glplib09.obj \
..\src\glplib10.obj \
..\src\glplib11.obj \
..\src\glplib12.obj \
..\src\glplpf.obj \
..\src\glplpp01.obj \
..\src\glplpp02.obj \
..\src\glplpx01.obj \
..\src\glplpx02.obj \
..\src\glplpx03.obj \
..\src\glplpx04.obj \
..\src\glplpx05.obj \
..\src\glplpx06.obj \
..\src\glplpx07.obj \
..\src\glplpx08.obj \
..\src\glplpx09.obj \
..\src\glpluf.obj \
..\src\glplux.obj \
..\src\glpmat.obj \
..\src\glpmpl01.obj \
..\src\glpmpl02.obj \
..\src\glpmpl03.obj \
..\src\glpmpl04.obj \
..\src\glpmpl05.obj \
..\src\glpmpl06.obj \
..\src\glpmps01.obj \
..\src\glpmps02.obj \
..\src\glpnet01.obj \
..\src\glpnet02.obj \
..\src\glpnet03.obj \
..\src\glpnet04.obj \
..\src\glpnet05.obj \
..\src\glppds.obj \
..\src\glpqmd.obj \
..\src\glprgr.obj \
..\src\glprng01.obj \
..\src\glprng02.obj \
..\src\glpscf.obj \
..\src\glpscg.obj \
..\src\glpscl.obj \
..\src\glpspm.obj \
..\src\glpspx01.obj \
..\src\glpspx02.obj \
..\src\glpsql.obj \
..\src\glpssx01.obj \
..\src\glpssx02.obj \
..\src\glptsp.obj
.c.obj:
cl.exe $(CFLAGS) /I..\include /Fo$*.obj /c $*.c
all: glpk.lib glpsol.exe
glpk.lib: $(OBJSET)
lib.exe /out:glpk.lib ..\src\*.obj
glpsol.exe: ..\examples\glpsol.obj glpk.lib
cl.exe $(CFLAGS) /Feglpsol.exe ..\examples\glpsol.obj glpk.lib
check: glpsol.exe
.\glpsol.exe --mps ..\examples\plan.mps
You just have to find the exact paths for "vcvars64.bat" and "nmake.exe".
I had the same problem, and this is what worked for me:
rem Build GLPK with Microsoft Visual Studio Express 2008 and
rem Windows Software Development Kit (SDK) for Windows Server 2008
rem NOTE: Make sure that HOME variable specifies correct path.
set HOME="c:\Program Files (x86)\Microsoft Visual Studio"
call %HOME%\2019\Community\VC\Auxiliary\Build\vcvars64.bat
copy config_VC9 config.h
%HOME%\2019\Community\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64\nmake.exe /f Makefile_VC9 all
%HOME%\2019\Community\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64\nmake.exe /f Makefile_VC9 check
pause

Logs directory permission denied error when running Artisan commands

I have a setup of docker with laravel and apache alongside mysql, when trying to run artisan command in the terminal of vscode i get :
There is no existing directory at "/var/www/html/storage/logs" and its not buildable: Permission denied
Apache setup in docker compose:
laravel-app:
build:
context: ./docker/app
args:
uid: ${UID}
container_name: laravel-app
environment:
- APACHE_RUN_USER=#${UID}
- APACHE_RUN_GROUP=#${UID}
volumes:
- .:/var/www/html
ports:
- ${HOST_PORT}:80
networks:
backend:
aliases:
- laravel-app
Dockerfile of apache
FROM php:7.2-apache
RUN apt-get update
# 1. development packages
RUN apt-get install -y \
git \
zip \
curl \
sudo \
unzip \
libicu-dev \
libbz2-dev \
libpng-dev \
libjpeg-dev \
libmcrypt-dev \
libreadline-dev \
libfreetype6-dev \
g++
# 2. apache configs + document root
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers
# 4. start with base php config, then add extensions
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
RUN docker-php-ext-install \
bz2 \
intl \
iconv \
bcmath \
opcache \
calendar \
mbstring \
pdo_mysql \
zip
# 5. composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# 6. we need a user with the same UID/GID with host user
# so when we execute CLI commands, all the host file's ownership remains intact
# otherwise command from inside container will create root-owned files and directories
ARG uid
RUN useradd -G www-data,root -u $uid -d /home/devuser devuser
RUN mkdir -p /home/devuser/.composer && \
chown -R devuser:devuser /home/devuser
even though the directory exists, also the commands run successfully from within the container. Should i always run the commands related to laravel artisan from the container, or there is something wrong?
Go to your project folder and open terminal
then,
run this command
sudo chmod -R 775 storage

DB2+IBM MQ; enable_MQFunctions = Error -- while connecting to database

I build docker's image containing IBM MQ 9.1, DB2express-c 9.7 + ubuntu 16.04 64bit.
I want to enable MQ functions(sending msg to queue) on my Db2 database.
But when I used enable_MQFunctions than I got this error:
*** Error -- while connecting to TEST
Make sure that user(db2inst1) and password(pass) are valid and that the DB2 instance has started.
*** enable_MQFunction finished with error
Database, user, pass are all okey. And i Don't understand than before this command w/o problems connected to my database
Dockerfile I today used(with only DB2 and IBM MQ, w/o IIB):
# © Copyright IBM Corporation 2015, 2017
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#==============================
#========================
#FROM centos:7
FROM ubuntu:16.04
#FROM ubuntu:17.10
#LABEL maintainer "Arthur Barr <arthur.barr#uk.ibm.com>, Rob Parker <PARROBE#uk.ibm.com>"
#LABEL "ProductID"="98102d16795c4263ad9ca075190a2d4d" \
# "ProductName"="IBM MQ Advanced for Developers" \
# "ProductVersion"="9.0.4"
# The URL to download the MQ installer from in tar.gz format
#oryginal ARG MQ_URL=https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev904_ubuntu_x86-64.tar.gz
ARG MQ_URL=http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev910_ubuntu_x86-64.tar.gz
#ARG MQ_URL=http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev80_linux_x86-64.tar.gz
#ARG MQ_URL=\\172.29.5.249\mqadv_dev910_ubuntu_x86-64.tar.gz
# The MQ packages to install
ARG MQ_PACKAGES="ibmmq-server ibmmq-java ibmmq-jre ibmmq-gskit ibmmq-web ibmmq-msg-.*"
#RUN rm /var/lib/apt/lists/*
RUN apt-get clean -y
RUN apt-get autoclean -y
RUN export DEBIAN_FRONTEND=noninteractive \
# Install additional packages required by MQ, this install process and the runtime scripts
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
# && yum update -y \
# && yum install -y \
bash \
bc \
ca-certificates \
coreutils \
curl \
debianutils \
file \
findutils \
gawk \
grep \
libc-bin \
lsb-release \
mount \
passwd \
procps \
sed \
tar \
util-linux \
# Download and extract the MQ installation files
&& export DIR_EXTRACT=/tmp/mq \
&& mkdir -p ${DIR_EXTRACT} \
&& cd ${DIR_EXTRACT} \
&& curl -LO $MQ_URL \
&& tar -zxvf ./*.tar.gz \
# Recommended: Remove packages only needed by this script
#
#&& package-cleanup --leaves --all \ <-------moje dodanie
# Recommended: Create the mqm user ID with a fixed UID and group, so that the file permissions work between different images
&& groupadd --system --gid 990 mqm \
&& useradd --system --uid 990 --gid mqm mqm \
&& usermod -G mqm root \
# Find directory containing .deb files
&& export DIR_DEB=$(find ${DIR_EXTRACT} -name "*.deb" -printf "%h\n" | sort -u | head -1) \
# Find location of mqlicense.sh
&& export MQLICENSE=$(find ${DIR_EXTRACT} -name "mqlicense.sh") \
# Accept the MQ license
&& ${MQLICENSE} -text_only -accept \
&& echo "deb [trusted=yes] file:${DIR_DEB} ./" > /etc/apt/sources.list.d/IBM_MQ.list \
# Install MQ using the DEB packages
&& apt-get update \
&& apt-get install -y $MQ_PACKAGES \
# Remove 32-bit libraries from 64-bit container
&& find /opt/mqm /var/mqm -type f -exec file {} \; \
| awk -F: '/ELF 32-bit/{print $1}' | xargs --no-run-if-empty rm -f \
# Remove tar.gz files unpacked by RPM postinst scripts
&& find /opt/mqm -name '*.tar.gz' -delete \
# Recommended: Set the default MQ installation (makes the MQ commands available on the PATH)
&& /opt/mqm/bin/setmqinst -p /opt/mqm -i \
# Clean up all the downloaded files
&& rm -f /etc/apt/sources.list.d/IBM_MQ.list \
&& rm -rf ${DIR_EXTRACT} \
# Apply any bug fixes not included in base Ubuntu or MQ image.
# Don't upgrade everything based on Docker best practices https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#run
&& apt-get upgrade -y sensible-utils \
# End of bug fixes
&& rm -rf /var/lib/apt/lists/* \
# Optional: Update the command prompt with the MQ version
&& echo "mq:$(dspmqver -b -f 2)" > /etc/debian_chroot \
&& rm -rf /var/mqm \
# Optional: Set these values for the Bluemix Vulnerability Report
&& sed -i 's/PASS_MAX_DAYS\t99999/PASS_MAX_DAYS\t90/' /etc/login.defs \
&& sed -i 's/PASS_MIN_DAYS\t0/PASS_MIN_DAYS\t1/' /etc/login.defs \
&& sed -i 's/password\t\[success=1 default=ignore\]\tpam_unix\.so obscure sha512/password\t[success=1 default=ignore]\tpam_unix.so obscure sha512 minlen=8/' /etc/pam.d/common-password
#==========db2 expres START====
#FROM centos:7
#MAINTAINER Leo Wu <leow#ca.ibm.com>
###############################################################
#
# System preparation for DB2
#
###############################################################
#********************z iib-mq-db2 git
RUN dpkg --add-architecture i386
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update && \
apt-get install -y --no-install-recommends \
curl \
bash \
bc \
coreutils \
curl \
debianutils \
findutils \
gawk \
grep \
libc-bin \
lsb-release \
libncurses-dev \
libstdc++6 \
gcc \
binutils \
make \
libpam0g:i386 \
lib32stdc++6 \
lib32gcc1 \
libcurl4-gnutls-dev:i386 \
numactl \
libaio1 \
libxml2 \
mount \
passwd \
procps \
rpm \
sed \
tar \
wget \
util-linux
RUN rm -rf /var/lib/apt/lists/*
RUN apt-get dist-upgrade -y
#******************
RUN groupadd db2iadm1 && useradd -G db2iadm1 db2inst1
# Required packages
#RUN yum install -y \
# vi \
# sudo \
# passwd \
# pam \
# pam.i686 \
# ncurses-libs.i686 \
# file \
# libaio \
# libstdc++-devel.i686 \
# numactl-libs \
# which \
# && yum clean all
ENV DB2EXPRESSC_DATADIR /home/db2inst1/data
# IMPORTANT Note:
# Due to compliance for IBM product, you have to host a downloaded DB2 Express-C Zip file yourself
# Here are suggested steps:
# 1) Please download zip file of db2 express-c from http://www-01.ibm.com/software/data/db2/express-c/download.html
# 2) Then upload it to a cloud storage like AWS S3 or IBM SoftLayer Object Storage
# 3) Acquire a URL and SHA-256 hash of file and pass it via Docker's build time argument facility
ARG DB2EXPRESSC_URL=ftp://ftp.software.ibm.com/software/data/db2/express/db2exc_images/db2exc_970_LNX_x86_64.tar.gz
#ARG DB2EXPRESSC_URL=http://lorenzana.gt/uploads/files/v10.5fp1_linuxx64_expc.tar.gz
#ARG DB2EXPRESSC_URL=\\172.29.5.249\public\image\v10.5fp1_linuxx64_expc.tar.gz
ADD db2expc.rsp /tmp/db2expc.rsp
ADD db2rfe.cfg /home/db2inst1/sqllib/instance/db2rfe.cfg
COPY db2expc.rsp /tmp
RUN curl -fkSLo /tmp/expc.tar.gz $DB2EXPRESSC_URL
RUN cd /tmp && tar xf expc.tar.gz
RUN rm -rf /home/db2inst1/sqllib
RUN mkdir /home/db2inst1/sqllib
RUN su - root -c "chmod -R 1777 /home/db2inst1/"
RUN su - db2inst1 -c "/tmp/expc/db2_install -f sysreq -b /home/db2inst1/sqllib"
# RUN su - db2inst1 -c "/tmp/expc/db2setup -r /tmp/db2expc.rsp" || echo "db2setup failed"
RUN echo '. /home/db2inst1/sqllib/db2profile' >> /home/db2inst1/.bash_profile \
&& rm -rf /tmp/db2* && rm -rf /tmp/expc* \
&& sed -ri 's/(ENABLE_OS_AUTHENTICATION=).*/\1YES/g' /home/db2inst1/sqllib/instance/db2rfe.cfg \
&& sed -ri 's/(RESERVE_REMOTE_CONNECTION=).*/\1YES/g' /home/db2inst1/sqllib/instance/db2rfe.cfg \
&& sed -ri 's/^\*(SVCENAME=db2c_db2inst1)/\1/g' /home/db2inst1/sqllib/instance/db2rfe.cfg \
&& sed -ri 's/^\*(SVCEPORT)=48000/\1=50000/g' /home/db2inst1/sqllib/instance/db2rfe.cfg \
&& mkdir $DB2EXPRESSC_DATADIR && chown db2inst1.db2iadm1 $DB2EXPRESSC_DATADIR
RUN su - db2inst1 -c "db2start && db2set DB2COMM=TCPIP && db2 UPDATE DBM CFG USING DFTDBPATH $DB2EXPRESSC_DATADIR IMMEDIATE && db2 create database db2inst1" \
&& su - db2inst1 -c "db2stop force" \
&& cd /home/db2inst1/sqllib/instance \
&& ./db2rfe -f ./db2rfe.cfg
#COPY docker-entrypoint.sh /entrypoint.sh
#ENTRYPOINT ["/entrypoint.sh"]
#VOLUME $DB2EXPRESSC_DATADIR
#EXPOSE 50000
#=========db2 express END ====
COPY *.sh /usr/local/bin/
COPY *.mqsc /etc/mqm/
COPY admin.json /etc/mqm/
COPY mq-dev-config /etc/mqm/mq-dev-config
RUN chmod +x /usr/local/bin/*.sh
# Always use port 1414 (the Docker administrator can re-map ports at runtime)
# Expose port 9443 for the web console
#VOLUME /home/db2inst1/data
EXPOSE 1414 9443 50000
ENV LANG=en_US.UTF-8
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
#ENTRYPOINT ["mq.sh"]
entrypoint.sh (with MQ and DB2 commands):
#======= start MQ =====
set -e
mq-license-check.sh
echo "----------------------------------------"
source mq-parameter-check.sh
echo "----------------------------------------"
setup-var-mqm.sh
echo "----------------------------------------"
which strmqweb && source setup-mqm-web.sh
echo "----------------------------------------"
mq-pre-create-setup.sh
echo "----------------------------------------"
source mq-create-qmgr.sh
echo "----------------------------------------"
source mq-start-qmgr.sh
echo "----------------------------------------"
source mq-dev-config.sh
echo "----------------------------------------"
source mq-configure-qmgr.sh
echo "----------------------------------------"
exec mq-monitor-qmgr.sh ${MQ_QMGR_NAME}
#======== z MQ - END ======
pid=0
function log_info {
echo -e $(date '+%Y-%m-%d %T')"\e[1;32m $#\e[0m"
}
function log_error {
echo -e >&2 $(date +"%Y-%m-%d %T")"\e[1;31m $#\e[0m"
}
function stop_db2 {
log_info "stopping database engine"
su - db2inst1 -c "db2stop force"
}
function start_db2 {
log_info "starting database engine"
su - db2inst1 -c "db2start"
}
function restart_db2 {
# if you just need to restart db2 and not to kill this container
# use docker kill -s USR1 <container name>
kill ${spid}
log_info "Asked for instance restart doing it..."
stop_db2
start_db2
log_info "database instance restarted on request"
}
function terminate_db2 {
kill ${spid}
stop_db2
if [ $pid -ne 0 ]; then
kill -SIGTERM "$pid"
wait "$pid"
fi
log_info "database engine stopped"
exit 0 # finally exit main handler script
}
trap "terminate_db2" SIGTERM
trap "restart_db2" SIGUSR1
if [ ! -f ~/db2inst1_pw_set ]; then
if [ -z "$DB2INST1_PASSWORD" ]; then
log_error "error: DB2INST1_PASSWORD not set"
log_error "Did you forget to add -e DB2INST1_PASSWORD=... ?"
exit 1
else
log_info "Setting db2inst1 user password..."
(echo "$DB2INST1_PASSWORD"; echo "$DB2INST1_PASSWORD") | passwd db2inst1 > /dev/null 2>&1
if [ $? != 0 ];then
log_error "Changing password for db2inst1 failed"
exit 1
fi
touch ~/db2inst1_pw_set
fi
fi
if [ ! -f ~/db2_license_accepted ];then
if [ -z "$LICENSE" ];then
log_error "error: LICENSE not set"
log_error "Did you forget to add '-e LICENSE=accept' ?"
exit 1
fi
if [ "${LICENSE}" != "accept" ];then
log_error "error: LICENSE not set to 'accept'"
log_error "Please set '-e LICENSE=accept' to accept License before use the DB2 software contained in this image."
exit 1
fi
touch ~/db2_license_accepted
fi
if [[ $1 = "-d" ]]; then
log_info "Initializing container"
start_db2
log_info "Database db2diag log following"
tail -f ~db2inst1/sqllib/db2dump/db2diag.log &
export pid=${!}
while true
do
sleep 10000 &
export spid=${!}
wait $spid
done
else
exec "$1"
fi
and than:
docker run -e LICENSE=accept -e MQ_QMGR_NAME=MQ321 -e DB2INST1_PASSWORD=pass -p 41419:1414 -p 9459:9443 -p 5015:50000 allall4r
And after all, I used command from : HERE
So I executed:
root:
usermod -G mqm db2inst1
/opt/mqm/bin/setmqinst -i -n Installation1 -p /opt/mqm
mqm user:
PATH=$PATH:/opt/mqm/bin
db2inst1 user:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/mqm/lib64
AMT_DATA_PATH=/opt/mqm
db2start
db2 create db testdb
db2 connect to testdb
cd ~/sqllib/cfg/mq
db2 –tvf amtsetup.sql
Upload with all files needed to build this image are here: UPLOAD LINK
Image will be about 3.1GB
I suspect that the cause of your symptom is that the account specified for enable_MQFunctions command line does not have a password at the time that enable_MQFunctions tries to run. You can prove this by looking at db2diag.log to see the exact authentication failure message, and/or by looking at the /etc/passwd entry for that account just before you run enable_MQFunctions.
You can expand the Dockerfile to configure the Db2 for MQ entirely during the docker build instead of running those steps after docker run or in entrypoints. That way you are responsible for all the steps inside the Dockerfile and it will be repeatable without manual intervention after the docker run command. It also means that your built image is pre-baked with all of the required configuration which will then be persistent. You need to have enough competence with scripting in the Dockerfile to get the desired outcome.
When correctly done, the enable_MQFunctions will operate properly during docker build, so if you are getting errors it's because you are doing it incorrectly.
I can successfully configure the database and run enable_MQFunctions all inside the Dockerfile, with these steps below (because of using a non-root install of Db2), so all the configuration is already in the built image.
after installing Db2 and before db2start the Dockerfile should
create /home/db2inst1/sqllib/userprofile (which will run whenever the instance-owner accounts dots in its db2profile from .bash_profile or .profile), to do these steps:
-- append /opt/mqm/lib64 to LD_LIBRARY_PATH
-- export AMT_DATA_PATH=/opt/mqm
-- prepend /opt/mqm/bin on the PATH
chown db2inst1:db2iadm1 /home/db2inst1/sqllib/userprofile
after installing Db2 and before db2start, the Dockerfile should run these steps:
-- db2set DB2COMM=TCPIP
-- db2set DB2ENVLIST=AMT_DATA_PATH
-- db2 -v update dbm cfg using federated yes immediate
set a password for db2inst1 account in the Dockerfile
the Dockerfile can then run db2start, create the database ( i call it sample, you can call it whatever you like) and run the fragment below as user db2inst1 to first create the required objects in the database used by the MQ functions:
su -db2inst1 -c "( db2 -v connect to sample ; \
db2 -tvf /home/db2inst1/sqllib/cfg/mq/amtsetup.sql; \
db2 -v list tables for schema DB2MQ ; \
exit 0 ) "
Notice that you have to run amtsetup.sql in a subshell ,as shown, to explicitly exit 0, because amtsetup.sql always returns non-zero exit code even when it completes successfully. So you want the docker build to continue in that case.
If all the above steps completed successfully and MQ is already successfully installed, later in the Dockerfile you can run the enable_MQFunctions as follows:
I use ARG INSTANCE_PASSWORD to specify the db2inst1 password, which can come from external.
su - db2inst1 -c "( . ./.profile ;\
db2start ;\
db2 -v activate database sample ;\
cd /home/db2inst1/sqllib/cfg ; \
/home/db2inst1/sqllib/bin/enable_MQFunctions -echo -force -n sample -u db2inst1 -p $INSTANCE_PASSWORD ; \
db2stop force ; \
exit 0)"
Problem was with environment variables. My image, after built, can't hold any variable. I try with export prefix but no change. So no password, no good LD_LIBRARY_PATH. Event after I change and logout, variable back to default.
After I used root -> passwd on my account (db2inst1) I can execute enable_MQFunction with good password
Next error is that I dont have valid license for db2..

spark-submit: command not found

A very simple question:
I try to use a bash script to submit spark jobs. But somehow it keeps complaining that it cannot find spark-submit command.
But when I just copy out the command and run directly in my terminal, it runs fine.
My shell is fish shell, here's what I have in my fish shell config: ~/.config/fish/config.fish:
alias spark-submit='/Users/MY_NAME/Downloads/spark-2.0.2-bin-hadoop2.7/bin/spark-submit'
Here's my bash script:
#!/usr/bin/env bash
SUBMIT_COMMAND="HADOOP_USER_NAME=hdfs spark-submit \
--master $MASTER \
--deploy-mode client \
--driver-memory $DRIVER_MEMORY \
--executor-memory $EXECUTOR_MEMORY \
--num-executors $NUM_EXECUTORS \
--executor-cores $EXECUTOR_CORES \
--conf spark.shuffle.compress=true \
--conf spark.network.timeout=2000s \
$DEBUG_PARAM \
--class com.fisher.coder.OfflineIndexer \
--verbose \
$JAR_PATH \
--local $LOCAL \
$SOLR_HOME \
--solrconfig 'resource:solrhome/' \
$ZK_QUORUM_PARAM \
--source $SOURCE \
--limit $LIMIT \
--sample $SAMPLE \
--dest $DEST \
--copysolrconfig \
--shards $SHARDS \
$S3_ZK_ZNODE_PARENT \
$S3_HBASE_ROOTDIR \
"
eval "$SUBMIT_COMMAND"
What I've tried:
I could run this command perfectly fine on my Mac OS X fish shell when I copy this command literally out and directly run.
However, what I wanted to achieve is to be able to run ./submit.sh -local which executes the above shell.
Any clues please?
You seem to be confused about what a fish alias is. When you run this:
alias spark-submit='/Users/MY_NAME/Downloads/spark-2.0.2-bin-hadoop2.7/bin/spark-submit'
You are actually doing this:
function spark-submit
/Users/MY_NAME/Downloads/spark-2.0.2-bin-hadoop2.7/bin/spark-submit $argv
end
That is, you are defining a fish function. Your bash script has no knowledge of that function. You need to either put that path in your $PATH variable or put a similar alias command in your bash script.
Make sure this command is added to path:
export PATH=$PATH:/Users/{your_own_path_where_spark_installed}/bin
For mac, open either one of these files ~/.bash, ~/.zprofile, ~/.zshrc and add the command below in the file.

Failed to Call Access Method Exception when Creating a MedicationOrder in FHIR

I am using this http://fhirtest.uhn.ca/baseDstu2 test FHIR server and it worked okay so far.
Now I am getting an HTTP-500 - Failed to Call Access Method exception.
Anyone has any idea on what has gone wrong?
This happens frequently. Probably because someone tested weird queries or similar that put the server in an unstable status.
I suggest posting a comment in https://chat.fhir.org/#narrow/stream/hapi to get the server restarted,
or install http://hapifhir.io/doc_cli.html which does basically the same but you have full control.
I built a Dockerfile:
FROM debian:sid
MAINTAINER Günter Zöchbauer <guenter#yyy.com>
ENV DEBIAN_FRONTEND noninteractive
RUN \
apt-get -q update && \
DEBIAN_FRONTEND=noninteractive && \
apt-get install --no-install-recommends -y -q \
apt-transport-https \
apt-utils \
wget \
bzip2 \
default-jdk
# net-tools sudo procps telnet
RUN \
apt-get update && \
rm -rf /var/lib/apt/lists/*
https://github.com/jamesagnew/hapi-fhir/releases/download/v2.0/hapi-fhir-2.0-cli.tar.bz2 && \
ADD hapi-* /hapi_fhir_cli/
RUN ls -la
RUN ls -la /hapi_fhir_cli
ADD prepare_server.sh /hapi_fhir_cli/
RUN \
cd /hapi_fhir_cli && \
bash -c /hapi_fhir_cli/prepare_server.sh
ADD start.sh /hapi_fhir_cli/
WORKDIR /hapi_fhir_cli
EXPOSE 5555
ENTRYPOINT ["/hapi_fhir_cli/start.sh"]
Which requires in the same directory as the Dockerfile
prepare_server.sh
#!/usr/bin/env bash
ls -la
./hapi-fhir-cli run-server --allow-external-refs &
while ! timeout 1 bash -c "echo > /dev/tcp/localhost/8080"; do sleep 10; done
./hapi-fhir-cli upload-definitions -t http://localhost:8080/baseDstu2
./hapi-fhir-cli upload-examples -c -t http://localhost:8080/baseDstu2
start.sh
#!/usr/bin/env bash
cd /hapi_fhir_cli
./hapi-fhir-cli run-server --allow-external-refs -p 5555
Build
docker build myname/hapi_fhir_cli_dstu2 -t . #--no-cache
Run
docker run -d -p 5555:5555 [image id from docker build]
Hope this helps.

Resources