`docker build` fails trying to install ubuntu packages - macos

Trying to build a simple ubuntu apache web server docker image, I get an error while the docker build command tries installing packages. I am using the Ubuntu base image in Docker to do this. Below is the code in my Dockerfile;
FROM ubuntu
RUN apt-get update
RUN apt-get install apache2
RUN apt-get install apache2-utils
RUN apt-get clean
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]
My Host OS is Mac OSX El Capitan, and the error I get when the build fails is;
The command '/bin/sh -c apt-get install apache2' returned a non-zero code: 1
and my docker build command is;
docker build -t="webserver" .
Any help please. Thanks in Advance.

You should use the '-y' apt-get flag when building an image.
apt-get will ask you permission to continue with apache installation, and since you can't interact with the apt-get while building the image, you must pass the '-y' flag that means 'yes' to apt-get prompt.
Try changing it to:
FROM ubuntu
RUN apt-get update
RUN apt-get install apache2 -y
RUN apt-get install apache2-utils -y
RUN apt-get clean
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]
or even:
FROM ubuntu
RUN apt-get update && apt-get install apache2 apache2-utils -y
RUN apt-get clean
EXPOSE 80
CMD ["apache2ctl", "-D", "FOREGROUND"]

Related

Installing Oracle Client Tools - Docker, Roundhouse, Oracle

I am trying to get Roundhouse running from a Docker image where I have some Oracle scripts, but currently when I execute the rh command against my Docker image I get the following error:
A type could not be created from the object you passed. "roundhouse.databases.oracle.OracleDatabase, roundhouse.databases.oracle" resolves to null.
I think this a result of not having the Oracle Client tools configured correctly in my Docker Image(https://github.com/chucknorris/roundhouse/wiki/Oracle).
I have downloaded the rpm files from https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html and I have managed to get the Oracle Client Tools installed but I carry on getting the above error so I assume that this is because I haven't configured the client tools correctly?
Can anyone advise what I am doing wrong?
FROM mcr.microsoft.com/dotnet/core/sdk:2.1
ENV PATH="$PATH:/root/.dotnet/tools"
ADD *.* /
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 alien -y
RUN sudo alien -i oracle-instantclient*-basic-*.rpm
RUN sudo alien -i oracle-instantclient*-devel-*.rpm
RUN sudo alien -i oracle-instantclient*-sqlplus-*.rpm
RUN echo /usr/lib/oracle/19.1/client/lib > /etc/ld.so.conf.d/oracle.conf
RUN sudo ldconfig
RUN dotnet tool install --global dotnet-roundhouse --version 1.2.1
ENTRYPOINT [ "rh"]
I had the same error when I tried to use the MS repo.
This worked for me:
Install the oficial oracle instant client container as
oracle/instantclient:19. Instruction here.
On top of that image build this Dockerfile
from oracle/instantclient:19
RUN microdnf install git RUN git clone https://github.com/chucknorris/roundhouse.git
RUN microdnf install dotnet-sdk-2.1
RUN cd roundhouse && dotnet tool install --global dotnet-roundhouse --version 1.2.1
ENTRYPOINT [ "rh"]

sqlalchemy connection issue while running docker image on local window machine

docker image builds successfully. But when actually I run docker image using docker run command to check if my application works fine. I got the below issue.
Please need guidance over this issue. Thanks a lot
issue:
sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")
(Background on this error at: http://sqlalche.me/e/dbapi)
connection string:
def connectiondb():
params = urllib.parse.quote_plus(
"DRIVER={SQL Server};SERVER=servername;DATABASE=dbname;UID=username;PWD=password")
engine = sqlalchemy.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)
metadata = MetaData(engine)
con = engine.connect()
dockerfile:
FROM python:latest
Bundle app source
COPY . /app
WORKDIR /app
Update
RUN pip install --upgrade pip
RUN apt-get update &&
apt-get install -y apt-transport-https &&
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - &&
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list &&
apt-get update &&
ACCEPT_EULA=Y apt-get install msodbcsql17 unixodbc-dev -y
RUN apt-get install libssl-dev
RUN pip install pyodbc==4.0.28
RUN pip install numpy==1.18.1
RUN pip install scikit-multiflow==0.4.1
RUN pip install Cython
RUN pip install scikit-learn==0.21.3
RUN pip install -r requirements.txt
EXPOSE 5000
CMD python ./app.py
return con, metadata,engine

Docker Install Wine Dockerfile EULA

I have a little problem to install Wine on my alpine image.
Here is my Dockerfile :
RUN dpkg --add-architecture i386 && sudo apt-get update
RUN sudo apt-get install software-properties-common python-software-properties
RUN sudo add-apt-repository ppa:ubuntu-wine/ppa
RUN sudo apt-get update
RUN sudo apt-get install wine1.8 winetricks
RUN sudo apt-get purge software-properties-common python-software-properties
RUN rm -rf /tmp/* /var/lib/apt/lists/* /root/.cache/*
CMD /bin/bash;
All seems to work well, but during the sudo apt-get install wine1.8 winetricks I have this EULA screen :
Of course I don't have the right to write "YES". I tried :
RUN echo "yes" | sudo apt-get install wine1.8 winetricks
RUN sudo apt-get -y install wine1.8 winetricks
What can I do ?
Note: In the interest of edification, I would love it if a more learned linux/docker user could explain the mechanics behind why my solution worked for me.
Possible Solution:
I encountered this exact problem. I must have tried every conceivable way to pass an argument via my Dockerfile that would accept the EULA; to include piping an echo of "yes" to the wine installation command, as you've tried, setting environment variables and so-on. So, you're not alone here. I did, however, find a very simple solution through experimentation.
It turns out that if you install the TrueType core fonts (the package the EULA is for) before installing wine, you can pass it the "yes" input like so and wine will never prompt for the EULA:
RUN echo "yes" | apt install ttf-mscorefonts-installer -y
I'm not sure why this is. I suspect that it's because installing wine installs several other packages/dependencies in the process, and the echo/pipe approach does not extend to all packages that wine attempts to install. Perhaps by installing the fonts separately, the wine installation script either disregards the package because it's already present, or some file within the font installation logs the EULA acceptance response.
Here's the contents of my Dockerfile. I'm on Ubuntu 16.04 LTS, using Docker version 18.02.0-ce, build fc4de44:
FROM ubuntu:16.04
RUN dpkg --add-architecture i386
RUN apt-get update -y
RUN echo "yes" | apt install ttf-mscorefonts-installer -y
RUN apt-get install wine -y
I see it's four months since this post was made, but if you haven't found a solution, I hope this helps!

launch basic bash script on docker build from windows system

I would like to construct a docker image based from script bash for provisioning my system.
I try to build my image and docker tell me "Successfully built" but when I try to launch this I can see this message : "No such file or directory" and I can't viewing container in Kitematic application.
If I launch docker inspect on my container (created correctly but not launched) I can view a ExitCode 127.
Can you help me to understand issue and also help me to launch correctly a simple script bash for provisionning image docker.
dockerfile :
FROM ubuntu:trusty
MAINTAINER barbie rambo <barbierambo#mymail.com>
RUN apt-get update \
&& apt-get install -y openjdk-7-jdk wget openssh-server tar vim
COPY scripts/base.sh /home/docker/scripts/base.sh
RUN chmod 744 /home/docker/scripts/base.sh
ENTRYPOINT /home/docker/scripts/base.sh
my base.sh script
#!/usr/bin/env bash
# Set non-interactive mode
#export DEBIAN_FRONTEND=noninteractive
# Update the box
apt-get -y update
apt-get -y install linux-headers-$(uname -r) build-essential
apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev
apt-get -y install curl unzip
apt-get -y install software-properties-common
apt-get -y install gnupg2
# others tools
sudo apt-get -y install nano
sudo apt-get -y install vim
sudo apt-get -y install aptitude
sudo apt-get -y install git
sudo apt-get -y install openjdk-8-jre
sudo apt-get -y install whois
sudo apt-get -y install dos2unix
check whether /home/docker/scripts/base.sh has EOL as UNIX/OSX Format, if not you can do EOL Conversion in Notepad++
open file in Notepad++ -> Edit -> EOL Conversion -> UNIX/OSX Format -> Save
then rebuild docker image
If you want to get into container ten run following:
docker ps -a
and use container id
docker exec -i -t [containerID] bash
and check whether file /home/docker/scripts/base.sh exists

how to install apt-get, raspbian

I am doing host target development within scratchbox. And apt-get is not installed in my target raspbian rootfile system.
What is the right apt-get package to use from here for raspbian ?
http://www.apt-get.org/main/
Should i use wget command for .deb package of apt-get ?
http://www.cyberciti.biz/tips/linux-wget-your-ultimate-command-line-downloader.html
http://www.thegeekstuff.com/2009/09/the-ultimate-wget-download-guide-with-15-awesome-examples/#more-1885
dpkg is installed in root filesystem of my target, i have checked it using whereis command
Please suggest, or can you suggest some link for installing apt-get itself. I am not able to find something related to it.
Any reply will be appreciable.
Looks like maybe debian apt package will get you there. I thought apt was just ubuntu but no.
The Raspbian FAQ is here: http://www.raspbian.org/RaspbianFAQ
In it you can grab a list of apps included in Rasbian:
http://archive.raspbian.org/raspbian/dists/wheezy/main/binary-armhf/Packages
You can grab the Raspbian package archive here:
http://archive.raspbian.org/raspbian/dists/wheezy/main/binary-armhf/Packages.gz
Extract it, then use dpkg to install apt-get.
Install Putty.exe and login with putty to your raspbian with ip-adress of your raspbian and you can install apt-get!
Install the following:
sudo apt-get update;
sudo apt-get install gcc;
sudo apt-get install autoconf;
sudo apt-get install libtool;
sudo apt-get install pkg-config;
sudo apt-get install libselinux1-dev;
sudo apt-get install liblockdev1-dev;
sudo apt-get install gawk;
sudo apt-get install g++;
sudo apt-get install c++;
sudo apt-get install libgudev-1.0-dev;
sudo apt-get install libudev-dev;
mkdir -p $HOME/distr/libcec;
wget -P $HOME/distr/libcec https://github.com/Pulse-Eight/libcec/archive/master.zip;
unzip $HOME/distr/libcec/master.zip -d $HOME/distr/libcec/;
cd $HOME/distr/libcec/libcec-master ./bootstrap;"
./configure --with-rpi-include-path=/opt/vc/include --with-rpi-lib-path=/opt/vc/lib --enable-rpi;
make;
sudo make install;
sudo apt-get install cec-utils;
sudo apt-get update
sudo apt-get dist-upgrade
sudo rpi-update
sudo reboot
After the reboot, is everything up-to-date and you have no problems anymore!

Resources