Docker build and Docker commit - rlaich/avctrec GitHub Wiki
Docker build vs Docker commit
Docker commit
Usually I used to save change of current running Container, it is more convenience when do operation in a running Container, but you don't know what is acutally file changes in commit.
Docker Build
Used to create docker image.
Advantage: Dockerfile is small, give it is match easy to give a save/export tar file for image.
Current Dockerfile
FROM ubuntu:20.04
MAINTAINER rlai<[email protected]>
ARG DEBIAN_FRONTEND=noninteractive
# Install system tools, apt-utils contains openssl
RUN apt-get update
RUN apt-get install -y dialog apt-utils
RUN apt-get install -y net-tools inetutils-ping sqlite curl zip tftp openssh-client ldap-utils
# SDK requirement
RUN apt-get install -y glibc-source locales sudo patch file
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
# Compile requirement:build-essential=gcc g++ make
RUN apt-get install -y git bc build-essential libffi-dev libssl-dev tcl lzop libxml2-dev squashfs-tools kmod bsdmainutils xxd
# Install python, default has python3.8
RUN apt-get -y install python3-pip python2
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
RUN python2.7 get-pip.py
# Install Buildbot
RUN pip3 install pycryptodome requests paramiko pexpect dnspython psutil spawn pysnmp pyserial xlsxwriter authlib xlwt
RUN pip3 install SQLAlchemy==1.3.23 buildbot==2.10.2 buildbot-www==2.10.2 buildbot-waterfall-view==2.10.2 buildbot-console-view==2.10.2 buildbot-grid-view==2.10.2 buildbot-worker==2.10.2 Twisted==22.10.0
RUN pip2.7 install openpyxl
# Test requirement
RUN apt-get install -y snmp libsnmp-dev snmp-mibs-downloader ipmitool expect
COPY etc/Lenovo-SMI-MIB.mib /usr/share/snmp/mibs/
RUN mkdir -p /home/svteam
# Init buildbot
# buildb work tree, build folder setup by host then mount when run container
# Add buildbot start/stop script to image
COPY bin/bbstart bin/bbstop bin/bbrestart /bin/
RUN chmod 755 /bin/bbstart /bin/bbstop /bin/bbrestart
# Add VPN and SSH connection files
RUN mkdir -p -m 0600 /root/.ssh
# COPY ssh key for gitlab repository connection
COPY ssh/id_rsa ssh/id_rsa.pub ssh/config ssh/known_hosts /root/.ssh/
RUN chmod 600 /root/.ssh/id_rsa
RUN eval $(ssh-agent -s) && ssh-add /root/.ssh/id_rsa
# Add git info
RUN git config --global --add user.name "Tester"
RUN git config --global --add user.email "[email protected]"
# SEP Tool workaround
RUN mkdir /usr/lib/symantec
RUN touch /usr/lib/symantec/version.sh && chmod 777 /usr/lib/symantec/version.sh
# Build openslp by source
COPY home/svteam/openslp-2.0.0.tar.gz /home/svteam/
WORKDIR /home/svteam
RUN tar -xvf openslp-2.0.0.tar.gz
WORKDIR /home/svteam/openslp-2.0.0
RUN ./configure && make && make install
RUN ln -s /usr/local/lib/libslp.so.1 /usr/lib/libslp.so.1
WORKDIR /root
RUN rm -rf /home/svteam/openslp-2.0.0
[Q1] Cannot do ssh-add when build docker image
[A] Run enable ssh-agent and ssh-add in the same line
RUN eval $(ssh-agent -s) && ssh-add /root/.ssh/id_rsa
Ref: