Configure Dockerfile to use impdp command when the container is created
<p>I am using wnameless/oracle-xe-11g docker image to create a new image file. And when I create a container from the new image I want the impdp command to be executed. How can this be achieved via Dockerfile?</p>

<p>Here is my Docker file</p>

<p>Dockerfile</p>

<pre><code># Base Image
FROM wnameless/oracle-xe-11g

# Create database_dump folder at / -location
RUN mkdir ../database_dumps 

# Copy the dump file and put it into database_dumps created earlier
COPY dump_file ../database_dumps

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

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

# 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.
</code></pre>

<p>For now I am doing this manually by ssh-ing into the container and running the impdp. I tried to do it using the</p>

<pre><code>CMD ["impdp", "system/oracle NOLOGFILE=Y DIRECTORY.."]
</code></pre>

<p>but does not work and throws exception.</p>

<p>So my question is "Is this possible"? If yes can you please provide the code example of how this can be achieved?</p>

<p>Thanks,</p>

<p>Update: The exception is not when creating the image but when trying to create a container from it. </p>

<p>So for example If I include this as the last line of my docker file</p>

<pre><code>CMD [“impdp”, “system/oracle NOLOGFILE=Y DIRECTORY=expdp_dir
DUMPFILE=SAMPLE_MASTER.EXPDP SCHEMAS=c##sample transform=OID:n”] 
</code></pre>

<p>Then do a </p>

<pre><code>docker build -t my/my_oracle .
</code></pre>

<p>and run it as</p>

<pre><code>docker run -d -p 49160:22 -p 49161:1521 my/my_oracle
</code></pre>

<p>and check for </p>

<pre><code>docker logs &lt;container_id&gt;
</code></pre>

<p>I see that</p>

<pre><code>/bin/sh: 1: ["impdp", : not found
</code></pre>