Is it possible to execute CMD at the middle of docker file?

I am installing hadoop-0.20.2 using docker. I have two files one is for java installation and another is for hadoop installation. I am starting services using CMD command

 cmd ["path/to/"]

Now, i want to to write third dockerfile which executes an example Map-Reduce job. But the problem is

  • Docker commands fails (in Windows)
  • boot2docker starting in Windows 7
  • Dockerize MySQL with database and tables
  • Bitbucket API version 1
  • Kubernetes Docker OS parameters vs Host OS parameters
  • How to list docker mounted volumes from within the container
  • Third docker file depends on second hadoop-docker file. fo eg:

     FROM sec_doc_file
     RUN /bin/hadoop fs -mkdir input

    It requires hadoop services. But hadoop services ll be started only after running second docker file. But i want to run it as part of third docker file before starting MR job? Is it possible? If so, please provide an example. If not, what could be the other possibilities?

     #something like
     From sec_doc_file
     RUN /bin/hadoop fs -mkdir input

  • how to configure docker container to run /usr/sbin/sshd upon startup
  • Cannot get more than one port to be exposed with docker [duplicate]
  • Docker: user namespace remapping not working although enabled for daemon
  • Docker interrupt proxy internet connection
  • Docker client communicating with docker host
  • Connection refused for Docker application on OSX
  • One Solution collect form web for “Is it possible to execute CMD at the middle of docker file?”

    The docker image you use as base for the new container is a base for files, not for processes supposed to be running. To do what you want you would need to start the process(es) you need during dockerbuild and run the commands to set up properly. Each RUN creates a new AUFS layer, but does not keep the possible previous running services. So, if you need a service to be up to perform some setup during docker build you would need to run it in one line (concatenating commands or with a custom script). Example:

    FROM Gops/sec_doc_file
    RUN path/to/ && /bin/hadoop fs -mkdir input

    So for setting up HDFS folders and files during docker build you’d need to run the hdfs daemons and perform the action you wish in the same RUN command:

    RUN /etc/hadoop/ &&\
        /opt/hadoop/sbin/ &&\
        /opt/hadoop/bin/hdfs dfs -mkdir input
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.