Issue
I am new to the docker world. I have to invoke a shell script that takes command line arguments through a docker container. Ex: My shell script looks like:
#!bin/bash
echo $1
Dockerfile looks like this:
FROM ubuntu:14.04
COPY ./file.sh /
CMD /bin/bash file.sh
I am not sure how to pass the arguments while running the container
Solution
Use the same file.sh
#!/bin/bash
echo $1
Build the image using the existing Dockerfile:
docker build -t test .
Run the image with arguments abc
or xyz
or something else.
docker run -ti --rm test /file.sh abc
docker run -ti --rm test /file.sh xyz
Answered By - BMW Answer Checked By - Marilyn (WPSolving Volunteer)