J
J
Julia Kovalenko2016-10-18 17:10:57
PHP
Julia Kovalenko, 2016-10-18 17:10:57

How to pass parameters to a container in Docker?

I have a phantomjs script.
I need to run this script in a container and pass parameters to this script.
In php, I ran it like this:

...
exec("phantomjs test.js $p1 $p2 $p3 $p4", $result);
...

I make a Dockerfile like this:
# our base image
FROM wernight/phantomjs:latest

# copy our application code
ADD test.js /tmp/test.js
WORKDIR /tmp

# specify the port number the container should expose
EXPOSE 5000

# run the application
CMD ["phantomjs", "./test.js"]

How can I pass parameters? And how to count them in the test.js script?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
Julia Kovalenko, 2016-10-18
@kovalenko_jul_s

Delete from Dockerfile CMD.
Collect an image.
And run like this:
sudo docker run imagename phantomjs test.js param

P
Philipp, 2016-10-18
@zoonman

Try this:
Or ordinal elements
CMD ["phantomjs", "./test.js", $1]

S
sirs, 2016-10-18
@sirs

Arg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question