Failure to run container after building IMAGE - docker

I am trying to set up IMAGE docker and I have a problem when I try to run the application and I would appreciate some help.
I define the following definition in the Dockerfile in order for the container to run the application for me:
CMD [ "python3", "-m", "JenkinsTestRunner/MultiTestsRunner" ]
But when I try to run the container docker build -t autmotionqa:latest . I get the error
/usr/bin/python3: No module named JenkinsTestRunner/MultiTestsRunner
When I perform DEBUG for each operation, I see that the CMD setting tries to run the application for me from the main directory that I set as WORKDIR: Automation
And basically the fact that the path I entered in the CMD was not captured (Automation/JenkinsTestRunner/MultiTestAutomation)
sudo docker build -t autmotionqa:latest .
Sending build context to Docker daemon 75.56MB
Step 1/14 : FROM ubuntu:20.04
---> 3bc6e9f30f51
Step 2/14 : RUN apt-get update -y && apt-get -y upgrade
---> Using cache
---> 4be823cb5aff
Step 3/14 : RUN apt-get install -y python3.9
---> Using cache
---> cabb45f4e49a
Step 4/14 : RUN apt-get install -y python3-pip
---> Using cache
---> 7d4e44db5391
Step 5/14 : RUN pip install pipenv
---> Using cache
---> 9567ded70eb0
Step 6/14 : RUN useradd -rm -d /home/bob -s /bin/bash -g root -G sudo -u 1001 bob
---> Using cache
---> 12f35e21a1a8
Step 7/14 : USER bob
---> Using cache
---> 9f5082d3cb8f
Step 8/14 : WORKDIR /home/bob/Automation/
---> Using cache
---> 8ab6631c348a
Step 9/14 : COPY Automation .
---> Using cache
---> 6429d1e723ab
Step 10/14 : RUN pwd && ls -l
---> Using cache
---> 707ccb98384d
Step 11/14 : RUN pipenv install --system
---> Using cache
---> 76b87b2b13bf
Step 12/14 : RUN cd JenkinsTestRunner/
---> Using cache
---> c7d68f093d03
Step 13/14 : RUN pwd && ls -l
---> Using cache
---> c63d2085772e
Step 14/14 : CMD [ "python3", "-m", "JenkinsTestRunner/MultiTestsRunner" ]
---> Running in 437f8ec53eac
Removing intermediate container 437f8ec53eac
---> 1ad52d9add10
Successfully built 1ad52d9add10
Successfully tagged autmotionqa:latest
####
sudo docker run autmotionqa:latest
/usr/bin/python3: No module named JenkinsTestRunner/MultiTestsRunner

Related

install maven in docker

I am trying to install and build one file using maven in Dockerfile, but getting an error mvn not found...
I referred to some articles but I did not find anything
can anyone please help me to why I am getting this and how to solve this?
my code
FROM ubuntu:latest
MAINTAINER ganeshthirumani
RUN apt-get update && apt-get install -y wget
ARG USER_HOME_DIR="/root"
#create a dir foe maven in opt
RUN mkdir /opt/maven
RUN mkdir /usr/share/maven
#RUN mkdir /usr/share/maven
#dwnl maven using link in tmp
RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz -O /tmp/maven.tar.gz
#extract the file
RUN cd /tmp && tar xvf maven.tar.gz
#copy the file into opt/maven
RUN cp -R /tmp/apache-maven-3.8.4/* /usr/share/maven/
#RUN cp /opt/files/* /usr/share/maven
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
#dwnl zip and move to /opt/files
RUN mkdir /opt/files
RUN wget <this is my zip file> -O /tmp/zip_file.zip
RUN cp /tmp/zip_file.zip /opt/files/
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
RUN mvn clean install -Pdevelopment
#RUN mvn clean install -Pdeployment
CMD ["mvn", "--version"]
and while building...
Sending build context to Docker daemon 97.28kB
Step 1/20 : FROM ubuntu:latest
---> d13c942271d6
Step 2/20 : MAINTAINER ganeshthirumani
---> Using cache
---> 83dbc04930a4
Step 3/20 : RUN apt-get update && apt-get install -y wget
---> Using cache
---> 5a26c629963f
Step 4/20 : ARG USER_HOME_DIR="/root"
---> Using cache
---> fea8fd2bb7f6
Step 5/20 : RUN mkdir /opt/maven
---> Using cache
---> 16a42d6b96c3
Step 6/20 : RUN mkdir /usr/share/maven
---> Using cache
---> 012f68749248
Step 7/20 : RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz -O /tmp/maven.tar.gz
---> Using cache
---> dc498bb88baf
Step 8/20 : RUN cd /tmp && tar xvf maven.tar.gz
---> Using cache
---> be08499a07db
Step 9/20 : RUN cp -R /tmp/apache-maven-3.8.4/* /usr/share/maven/
---> Using cache
---> 7a705ce7213d
Step 10/20 : RUN apt-get update && apt-get install -y openjdk-8-jdk && apt-get clean;
---> Using cache
---> 452e0b263645
Step 11/20 : RUN apt-get update && apt-get install ca-certificates-java && apt-get clean && update-ca-certificates -f;
---> Using cache
---> d65d98457da5
Step 12/20 : ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
---> Using cache
---> b8cacc77d6b0
Step 13/20 : RUN export JAVA_HOME
---> Using cache
---> 1a5918571b65
Step 14/20 : RUN mkdir /opt/files
---> Using cache
---> 66d092f96235
Step 15/20 : RUN wget https://drive.google.com/file/d/1IutshyYqlcTw_MkfC1NJzU9AH8B-W2Fa/view?ts=61f24be4 -O /tmp/zip_file.zip
---> Using cache
---> 7180fa09993b
Step 16/20 : RUN cp /tmp/zip_file.zip /opt/files/
---> Using cache
---> bc861eb85449
Step 17/20 : ENV MAVEN_HOME /usr/share/maven
---> Using cache
---> be97d22b8558
Step 18/20 : ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
---> Using cache
---> 7874ed478f2f
Step 19/20 : RUN mvn clean install -Pdevelopment
---> Running in 5b58132ba431
/bin/sh: 1: mvn: not found
The command '/bin/sh -c mvn clean install -Pdevelopment' returned a non-zero code: 127
and I have seen that the basic directories are:
for maven home MAVEN_HOME /usr/share/maven
for config---> MAVEN_CONFIG "$USER_HOME_DIR/.m2 and where user_home_dir is a root
thanks in advance

Cannot create deno docker image

I want to create deno docker image using Dockerfile
FROM alpine:latest
WORKDIR /
RUN apk update && \
apk upgrade
RUN apk add curl
RUN curl -fsSL https://deno.land/x/install/install.sh | sh
ENV DENO_INSTALL="/root/.deno"
ENV PATH="${DENO_INSTALL}/bin:${PATH}"
RUN deno --help
But when run docker build -t deno . it shows at last /bin/sh: deno: not found
full output:
Sending build context to Docker daemon 54.78kB
Step 1/8 : FROM alpine:latest
---> f70734b6a266
Step 2/8 : WORKDIR /
---> Using cache
---> b1bbfa810906
Step 3/8 : RUN apk update && apk upgrade
---> Using cache
---> a7761425faba
Step 4/8 : RUN apk add curl
---> Using cache
---> 9099d4f65cb1
Step 5/8 : RUN curl -fsSL https://deno.land/x/install/install.sh | sh
---> Using cache
---> b4ea95c69a73
Step 6/8 : ENV DENO_INSTALL="/root/.deno"
---> Using cache
---> bdc7e1e85e9c
Step 7/8 : ENV PATH="${DENO_INSTALL}/bin:${PATH}"
---> Using cache
---> d35db1caba71
Step 8/8 : RUN deno --help
---> Running in d1ca4e1d0dc6
/bin/sh: deno: not found
The command '/bin/sh -c deno --help' returned a non-zero code: 127
Alpine is missing glibc which is needed for deno to run.
You can use frolvlad/alpine-glibc:alpine-3.11_glibc-2.31 instead and it will work fine.
FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.31
WORKDIR /
RUN apk update && \
apk upgrade
RUN apk add curl
RUN curl -fsSL https://deno.land/x/install/install.sh | sh
ENV DENO_INSTALL="/root/.deno"
ENV PATH="${DENO_INSTALL}/bin:${PATH}"
RUN deno --help
I recommend building a specific deno version, for that, you should use:
curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.0.0
FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.31
ENV DENO_VERSION=1.0.0
# ...
RUN curl -fsSL https://deno.land/x/install/install.sh | sh -s v${DENO_VERSION}
# ...
You can also check deno-docker

Error building new workspace using docker-compose when running "apt-get update -yqq"

I am setting up a new project using Laradock in Ubuntu 18.04. I verified that docker-compose is correctly installed and that the images were downloaded correctly. When running
$ sudo docker-compose up -d mysql nginx phpmyadmin redis php-worker
It returns the following error:
+ apt-get update -yqq
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/dists/xenial/InRelease Temporary failure resolving 'ppa.launchpad.net'
W: Some index files failed to download. They have been ignored, or old ones used instead.
After running the command 'docker-compose up':
path_to_laradock/laradock$ sudo docker-compose up -d mysql nginx phpmyadmin redis php-worker
Building workspace
Step 1/251 : ARG LARADOCK_PHP_VERSION
Step 2/251 : FROM laradock/workspace:2.6.1-${LARADOCK_PHP_VERSION}
---> 9e3231c96fa9
Step 3/251 : LABEL maintainer="Mahmoud Zalt <mahmoud#zalt.me>"
---> Using cache
---> 2a0571fff132
Step 4/251 : ARG LARADOCK_PHP_VERSION
---> Using cache
---> fd7c28e61b6c
Step 5/251 : ENV DEBIAN_FRONTEND noninteractive
---> Using cache
---> 8dfd11e8a07b
Step 6/251 : ARG CHANGE_SOURCE=false
---> Using cache
---> f72c34b26b28
Step 7/251 : RUN if [ ${CHANGE_SOURCE} = true ]; then sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list && sed -i 's/security-cdn.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list ;fi
---> Using cache
---> c8325ad16886
Step 8/251 : USER root
---> Using cache
---> c36347410846
Step 9/251 : ARG PUID=1000
---> Using cache
---> 37bb8c1e61cf
Step 10/251 : ENV PUID ${PUID}
---> Using cache
---> b6076ea8d56f
Step 11/251 : ARG PGID=1000
---> Using cache
---> 05e5eb9ee8a7
Step 12/251 : ENV PGID ${PGID}
---> Using cache
---> e0987ed2353e
Step 13/251 : ARG CHANGE_SOURCE=false
---> Using cache
---> 4e13d59b9edc
Step 14/251 : ARG UBUNTU_SOURCE
---> Using cache
---> 5dfae87036c0
Step 15/251 : COPY ./sources.sh /tmp/sources.sh
---> Using cache
---> 077233c36a6e
Step 16/251 : RUN if [ ${CHANGE_SOURCE} = true ]; then /bin/sh -c /tmp/sources.sh && rm -rf /tmp/sources.sh ;fi
---> Using cache
---> e58f5c8ce0f8
Step 17/251 : RUN set -xe; apt-get update -yqq && pecl channel-update pecl.php.net && groupadd -g ${PGID} laradock && useradd -u ${PUID} -g laradock -m laradock -G docker_env && usermod -p "*" laradock -s /bin/bash && apt-get install -yqq apt-utils libzip-dev zip unzip php${LARADOCK_PHP_VERSION}-zip nasm && php -m | grep -q 'zip'
---> Running in df3b3e0be1e9
+ apt-get update -yqq
What configuration file could be causing the error?
Thanks!
It was a problem with the DNS.
After modifying 'docker' file in '/etc/default/' I changed the default DNS. I restored the default values and everything worked normally again.
It looks like this:
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

File copied to Docker image dissappears

I have this multi-stage Dockerfile. I make a program in the build image, tar up the contents, copy it in the main image, untar it. Once the container starts, when i go into the container, I can no longer find the file. However, using "ls" commands I'm able to see that it was copied over and extracted. I don't know if this has anything to do with the fact that I have the root directory of the application as a volume. I did that to speed up the builds after making code changes.
docker-compose.yml
version: "3"
services:
web:
build: .
ports:
- "5000:5000"
- "5432:5432"
volumes:
- ".:/code"
environment:
- PORT=5000
# TODO: Should be set to 0 for production
- PYTHONUNBUFFERED=1
Dockerfile
# Build lab-D
FROM gcc:8.2.0 as builder
RUN apt-get update && apt-get install -y libxerces-c-dev
WORKDIR /lab-d/
RUN git clone https://github.com/lab-d/lab-d.git
WORKDIR /lab-d/lab-d/
RUN autoreconf -if
RUN ./configure --enable-silent-rules 'CFLAGS=-g -O0 -w' 'CXXFLAGS=-g -O0 -w' 'LDFLAGS=-g -O0 -w'
RUN make
RUN make install
WORKDIR /lab-d/
RUN ls
RUN tar -czf labd.tar.gz lab-d
# Main Image
FROM library/python:3.7-stretch
RUN apt-get update && apt-get install -y python3 python3-pip \
postgresql-client \
# lab-D requires this library
libxerces-c-dev \
# For VIM
apt-file
RUN apt-file update && apt-get install -y vim
RUN pip install --upgrade pip
COPY requirements.txt /
RUN pip3 install --trusted-host pypi.org -r /requirements.txt
RUN pwd
RUN ls .
COPY --from=builder /lab-d/labd.tar.gz /code/labd.tar.gz
WORKDIR /code
RUN pwd
RUN ls .
RUN tar -xzf labd.tar.gz
RUN ls .
run pwd
RUN ls .
CMD ["bash", "start.sh"]
docker-compose build --no-cache
...
Step 19/29 : RUN pwd
---> Running in a856867bf69a
/
Removing intermediate container a856867bf69a
---> f1ee3dca8500
Step 20/29 : RUN ls .
---> Running in ee8da6874808
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
requirements.txt
root
run
sbin
srv
sys
tmp
usr
var
Removing intermediate container ee8da6874808
---> e8aec80955c9
Step 21/29 : COPY --from=builder /lab-d/labd.tar.gz /code/labd.tar.gz
---> 72d14ab4e01f
Step 22/29 : WORKDIR /code
---> Running in 17873e785c17
Removing intermediate container 17873e785c17
---> 57e8361767ca
Step 23/29 : RUN pwd
---> Running in abafd210abcb
/code
Removing intermediate container abafd210abcb
---> c6f430e1b362
Step 24/29 : RUN ls .
---> Running in 40b9e85261c2
labd.tar.gz
Removing intermediate container 40b9e85261c2
---> f9ee8e04d065
Step 25/29 : RUN tar -xzf labd.tar.gz
---> Running in 6e60ce7e1886
Removing intermediate container 6e60ce7e1886
---> 654d3c791798
Step 26/29 : RUN ls .
---> Running in 0f445b35f399
lab-d
labd.tar.gz
Removing intermediate container 0f445b35f399
---> 7863a15534b1
Step 27/29 : run pwd
---> Running in 9658c6170bde
/code
Removing intermediate container 9658c6170bde
---> 8d8e472a1b95
Step 28/29 : RUN ls .
---> Running in 19da5b77f5b6
lab-d
labd.tar.gz
Removing intermediate container 19da5b77f5b6
---> 140645efadbc
Step 29/29 : CMD ["bash", "start.sh"]
---> Running in 02b006bdf868
Removing intermediate container 02b006bdf868
---> 28d819321035
Successfully built 28d819321035
Successfully tagged -server_web:latest
start.sh
#!/bin/bash
# Start the SQL Proxy (Local-only)
pwd
ls .
./cloud_sql_proxy -instances=api-project-123456789:us-central1:sq=tcp:5432 \
-credential_file=./config/google_service_account.json &
ls .
# Override with CircleCI for other environments
cp .env.development .env
ls .
python3 -u ./server/server.py
In your Dockerfile, you
COPY --from=builder /lab-d/labd.tar.gz /code/labd.tar.gz
WORKDIR /code
RUN tar -xzf labd.tar.gz
But then your docker-compose.yml specifies
volumes:
- ".:/code"
That causes the current directory on the host to be mounted over /code in the container, and every last bit of work your Dockerfile does is hidden.

Building druid got stuck and does not move forward

I am trying to build druid using the docker file provided on the pulsarIO/dockerfiles
But it does not gets build fully and gets stuck at some point:
The Stack looks like this :
shivansh#localhost:~/Documents/Huawei/pulsar/docker-files/pulsarReporting/druid$ sudo sh build
Sending build context to Docker daemon 35.33 kB
Step 1 : FROM ubuntu:14.04
---> 45e5f47e0036
Step 2 : MAINTAINER Xu,Xin <xinxu1#ebay.com>
---> Using cache
---> 46d0ac73c2ed
Step 3 : RUN apt-get update
---> Using cache
---> 7ecac41ee372
Step 4 : RUN apt-get install -y vim less net-tools inetutils-ping curl git telnet nmap socat dnsutils netcat tree htop unzip sudo software-properties-common
---> Using cache
---> be238924e32a
Step 5 : RUN echo 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main' > /etc/apt/sources.list.d/java.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 && apt-get update && echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && apt-get install -y oracle-java7-installer
---> Using cache
---> 7b462d5c7b60
Step 6 : RUN wget -q -O - http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz | tar -xzf - -C /usr/local && ln -s /usr/local/apache-maven-3.2.5 /usr/local/apache-maven && ln -s /usr/local/apache-maven/bin/mvn /usr/local/bin/mvn
---> Using cache
---> 8d93a2bebc76
Step 7 : RUN mvn dependency:get -Dartifact=io.druid:druid-services:0.7.3
---> Using cache
---> 1e3fccd70f5b
Step 8 : RUN curl http://static.druid.io/artifacts/releases/druid-0.7.3-bin.tar.gz | tar xz
---> Using cache
---> 73d092b0fc55
Step 9 : RUN mv druid-0.7.3 druid-services
---> Using cache
---> 278eb7e7f30c
Step 10 : RUN apt-get install -y mysql-server && sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
---> Using cache
---> 9864be2ef7ce
Step 11 : ADD config druid-services/config
---> Using cache
---> 4f3d4b4dd1d7
Step 12 : ADD ./mysql.ddl mysql.ddl
---> Using cache
---> 51b798fa62da
Step 13 : RUN mysqld_safe & mysqladmin --wait=5 ping && mysql < mysql.ddl && mysqladmin shutdown
---> Using cache
---> f7ddfd9fbd3e
Step 14 : WORKDIR /druid-services
---> Using cache
---> cc01a554687d
Step 15 : RUN java -classpath "config/_common:lib/*" io.druid.cli.Main tools pull-deps
---> Running in d8a09c205f3d
Oct 25, 2016 7:23:31 AM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 5.1.3.Final
I cannot understand exactly what the problem is ! And If i try to run the
sudo docker ps -a
command to see the running containers I cannot see the druid one there !
Any help is appreciated !

Resources