Rustam Issabekov
Rustam Issabekov

Reputation: 3507

difference in how mv command acts in dockerfile and on my local linux

I am looking at the following jboss/wildfly docker file which has the following command:

mv $HOME/wildfly-$WILDFLY_VERSION $JBOSS_HOME

where $WILDFLY_VERSION=17.0.1.Final and $JBOSS_HOME=/opt/jboss/wildfly.Thus the resulting command translates to:

mv $HOME/wildfly-17.0.1.Final /opt/jboss/wildfly

Later in the file we start the wildfly like this:

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]

So I assume that the mv command from the above took the content of $HOME/wildfly-17.0.1.Final directory and put it inside the /opt/jboss/wildfly directory.

However, if I try to recreate the steps from the dockerfile on my local machine (ubuntu 18.04) when I do mv $HOME/wildfly-17.0.1.Final /opt/jboss/wildfly, I end up with the following directory structure /opt/jboss/wildfly/wildfly-17.0.1.Final. That is, the wildfly-17.0.1.Final directory itself is copied into /opt/jboss/wildfly, rather than its content. Can somebody please explain why I get this result locally?

Upvotes: 1

Views: 286

Answers (1)

Viktova
Viktova

Reputation: 612

$JBOSS_HOME path doesn't exist.

What the mv command does is actually replace the non-existent directory with the $HOME/wildfly-17.0.1.Final folder. That been said, the content of $HOME/wildfly-17.0.1.Final/ will be moved into $JBOSS_HOME replacing the name of the folder from "wildfly-17.0.1.Final" into "wildfly".

Simple Example would be as follow:

Create an empty dir and touch a file inside it, then try to do:

mv dir /var/lib/non_existing_folder

dir will be moved as is and replace "non_existing_folder".

Upvotes: 5

Related Questions