-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
When executing a Dockerfile, each RUN command creates a new image and stores it. The next RUN command then creates a new instance using that image. This means that even if a SSH session is started in one RUN command (like this: /etc/init.d/ssh start), if a ssh command is given in ANOTHER RUN command, the SSH session is not live, resulting in a cannot assign requested address error. Therefore, if you need to ssh into a live session to perform an action inside a Dockerfile, you must run all the commands inside a single RUN command, concatenated with &&.
Example:
RUN /etc/init.d/ssh start && \
./sbin/start-dfs.sh; ./sbin/start-yarn.sh && \
./bin/hdfs dfs -mkdir -p /tmp/hive && ./bin/hdfs dfs -mkdir -p /user/hive/warehouse && \
./bin/hdfs dfs -chmod g+w /tmp && ./bin/hdfs dfs -chmod 777 /tmp/hive && \
./bin/hdfs dfs -chmod g+w /user/hive && ./bin/hdfs dfs -chmod g+w /user/hive/warehouse && \
/root/hive/bin/schematool -dbType derby -initSchema && \
./sbin/stop-yarn.sh; ./sbin/stop-dfs.sh