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
# Create oracle_dump folder at / -location
RUN mkdir /var/lib/sharedata;
# Give permission
RUN chmod 777 '/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.
&& bin/bash -c "/u01/app/oracle/product/184.108.40.206/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/220.127.116.11/dbhome_1/bin \
#Export oracle_home and related
RUN echo 'export ORACLE_HOME=/u01/app/oracle/product/18.104.22.168/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.
A Dockerfile is the blueprint that instructions how to build an image. Thus said, I have no idea how to “complete” this Dockerfile as it makes no sense to way it is now.
May I suggest to re-read the dockerhub description of the base image? It specificly mentions how to execute arbitrary shell or sql script during contaienr start. Please validate wether it is an option to archive what you want.
I understand, but I need you to read chapter 2 which explains how images work. With the new understanding, I like you to create a new post about what you want, this time with every part where it belongs - most of your Dockerfile content looks like it doesn’t belong here.
Reading chapter 2 will help you to understand wether its a good idea to make the database creation part of the image or part of the image’s entrypoint script - which is used by a container on every start.
If all of this is too much, I would suggest to NOT create your own image, but instead follow instructions from the section " Running scripts at startup" from the dockerhub description of the absolutapps/oracle-12c-ee.
N.B the image was created 6 years ago and is not patched since. So be prepared that it has a lot of vulnerabile in the os level packages and the installed database itself.
Maybe I quite understand, so now I will try to two ways you suggested.
Now I want to configure dockerfile of absolutapps by add shell sciprts into entrypoint.sh or add CMD imdp command in dockerfile. I build that docker file to a new image.
When I run with a new name image it shows me the permission about exec entrypoint.sh .