Create docker file includes imdp dump file

Hi everyone,
Now I want to configure docker file to run imdp command when container is created. This is my docker file based on a source from web by someone that I try to create. Anyone can help me to complete it. Thank you in advance.

# Base Image
FROM absolutapps/oracle-12c-ee:latest

# Create oracle_dump folder at / -location
RUN mkdir  /var/lib/sharedata;

# Give permission
RUN chmod 777 '/var/lib/sharedata';

#VOLUME
MOUNT /home/huynn/Downloads/share:/var/lib/sharedata

# Give permission to user oracle on oracle folder to create tablespace
and related operations

RUN chown -R oracle /u01/app/oracle/oradata/orcl

# Alter datafiles
Alter tablespace USERS add datafile '/u01/app/oracle/oradata/orcl/users02.dbf' size 30G autoextend on;
Alter tablespace USERS add datafile '/u01/app/oracle/oradata/orcl/users03.dbf' size 30G autoextend on;

# RUN the database initial sql.(create tablespace, create user etc)
ADD init.sql /docker-entrypoint-initdb.d/

# Here is where I want to call the impdp command. when a container is
created from this image.

CMD /usr/sbin/startup.sh 
&& bin/bash  -c "/u01/app/oracle/product/12.1.0.2/dbhome_1/bin/impdp
sys/oracle   schemas = test DIRECTORY=ORACLE_DUMP  DUMPFILE= mydumpfile  exclude=index,constraint,statistics,grant PARALLEL=4 nologfle=y
" 
&& /usr/sbin/sshd -D


# Add env variables for oracle_home and related
ENV ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1/bin \
ORACLE_SID=xe

#Export oracle_home and related
RUN echo 'export ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1/bin' >> etc/bash.bashrc
RUN echo 'export PATH=$ORACLE_HOME/bin:$PATH' >> /etc/bash.bashrc
RUN echo 'export ORACLE_SID=xe' >> /etc/bash.bashrc

P/s: because I am new one to docker, so I am very happy if you can describe detail about the solution.

Can you adjust the CMD line to also run the impdp command?

That is my configure docker file

FROM absolutapps/oracle-12c-ee-base

ENV INIT_MEM_PST 40
ENV SW_ONLY false
ENV TERM dumb

COPY entrypoint.sh /

EXPOSE 1521
EXPOSE 8080
EXPOSE 5500

VOLUME [“/u01/app/oracle”]

RUN chmod +x entrypoint.sh

ENTRYPOINT [“/entrypoint.sh”]

CMD [“impdp”, “schemas = SA DIRECTORY=ORACLE_DUMP DUMPFILE=SA08062022BOD_DP.DMP exclude=index,constraint,statistics,grant PARALLEL=4”]

But now it show me when I run docker run with my new name image:

Nothing has been configured. Please run ‘/entrypoint.sh’ to install or start db

Import: Release 12.1.0.2.0 - Production on Mon Jun 27 03:47:00 2022

Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.

Username: UDI-00005: unexpected End-Of-File encountered while reading input.

But when I run with absolutapps/oracle-12c-ee, it is fine.
I use origin of absolutapps 's dockerfile and add one last rows CMD to imdp command.

Your latest Dockerfile looks very similar to this one. In their readme they say that scripts placed in /oracle.init.d/ will be run after the database starts up. Maybe instead of using CMD in your Dockerfile, you could write a shell script to run the impdp command.