background
demand : Will the existing one java Program migration to containerized deployment . The general process is , According to the current physical machine deployment environment , With centos7 Is the base mirror , Add the program to run the use of jdk and oracle client Environmental Science , Then specify the start command .
Document preparation
$ ls
Dockerfile test-3.3.tar.gz jdk-8u251-linux-x64.tar.gz oracle-instantclient19.8.tar.gz README.md
To write Dockerfile
$ vi Dockerfile
FROM centos:7
MAINTAINER Peter<[email protected]>
ADD oracle-instantclient19.8.tar.gz /app
ADD test-3.3.tar.gz /app
ADD jdk-8u251-linux-x64.tar.gz /app
RUN yum install -y libaio
RUN rpm -ivh /app/oracle-instantclient19.8/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
RUN rpm -ivh /app/oracle-instantclient19.8/oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm
RUN rpm -ivh /app/oracle-instantclient19.8/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm
RUN rpm -ivh /app/oracle-instantclient19.8/oracle-instantclient19.8-tools-19.8.0.0.0-1.x86_64.rpm
ENV JAVA_HOME /app/jdk1.8.0_251
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV ORACLE_HOME /usr/lib/oracle/19.8/client64
ENV PATH $PATH:$ORACLE_HOME/bin
ENV LD_LIBRARY_PATH $ORACLE_HOME/lib:$LD_LIBRARY_PATH
VOLUME /app/test-3.3/conf
ENTRYPOINT ["/app/test-3.3/bin/startup.sh", "-ftp", "y"]
$
Build a mirror image
$ docker build -t test:3.3 .
Look at the mirror image
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
test 3.3 2f1c200490ae 2 days ago 1.1GB
$
Run container
$ docker run -d \
-v /work/test-3.3-conf:/app/test-3.3/conf \
--name test \
test:3.3
$
Export the mirror
$ docker save test:3.3 > test-3.3.tar
$ ls fpf-xml2db-lte-nrm.tar
fpf-xml2db-lte-nrm.tar
$
Import mirror
$ docker load < fpf-xml2db-lte-nrm.tar