The Daily Shaarli
#!/bin/bash
servers="server1;server2;server3"
IFS=';' read -r -a array <<< "$servers"
rand=$[ $RANDOM % ${#array[@]} ]
echo ${array[$rand]}t also adds complexity to the Dockerfile language when there are clear workarounds. Don't push so much config in the parent Dockerfile and leave if for the inheriting images instead. (aka: stop sourcing random images on docker hub :D)
Since docker 17.05 there is also a new way to do multi-stage builds that removes most of the need for this issue (this is a single Dockerfile):
FROM nginx AS source-image
FROM scratch
COPY --from=source-image / /
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"]
EDIT: Forgot to say, the second solution squashes all previous layers. I don't think it's a big deal but it's good to know.
