I am calling the docker build command from a shell script and I wanna pass an array in the build args .. First question can I really do that ? If yes then how do i iterate inside the docker file. A Small example will really help.
You can pass a space-separated string to builds then convert string to an array or just loop over the string.
Dockerfile
FROM alpine
ARG items
RUN for item in $items; do \
echo "$item"; \
done;
pass value during build time
docker build --build-arg items="item1 item2 item3 item4" -t my_image .
output
Step 3/3 : RUN for item in $items; do echo "$item"; done;
---> Running in bee1fd1dd3c6
item1
item2
item3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With