user2824073
user2824073

Reputation: 2485

Unable to execute shell script with parameter from Dockerfile

I'm creating a Dockerfile to customize an image named jboss/wildfly. I need to execute the following command:

/opt/jboss/wildfly/bin/jboss-cli.sh --file=/opt/jboss/wildfly/bin/add-datasource.cli

The command works fine on my host machine, when translated into Dockerfile:

CMD ["/opt/jboss/wildfly/bin/jboss-cli.sh", "--file=","/opt/jboss/wildfly/bin/add-datasource.cli"]

The following error is returned:

'add-datasource.cli' is assumed to be a command(s) but the commands to execute have been specified by another argument: [--file]

Any help ?

Upvotes: 1

Views: 1651

Answers (1)

dnephin
dnephin

Reputation: 28060

The problem is the syntax you're using. You've split the --file= incorrectly. You need either:

CMD ["/opt/jboss/wildfly/bin/jboss-cli.sh", "--file=/opt/jboss/wildfly/bin/add-datasource.cli"]

or

CMD ["/opt/jboss/wildfly/bin/jboss-cli.sh", "--file", "/opt/jboss/wildfly/bin/add-datasource.cli"]

The command you have specified would parse as --file= /opt/... which isn't a valid command line.

Upvotes: 1

Related Questions