I have a bash script that I want to dockerize but I’m having issues with both the ENTRYPOINT
and CMD
directives.
Here’s my Dockerfile:
FROM ubuntu:22.04
# NOTE: these can be overridden with `--build-arg KEY=VALUE`
ARG ...
WORKDIR /scripts
COPY . .
# Install required packages
RUN ...
# Make sure the script is executable
RUN chmod a+x my-script.sh
# Set the entrypoint to use bash
ENTRYPOINT [ "bash" ]
# Run the script
CMD [ "./my-script.sh", "-u", $URL, "-k", $KEY, "-d", $DEBUG ]
I’ve done a few iterations and I kept getting different kind of errors. I’ve already deleted the images that I built and the containers so I don’t have the errors to share.
Basically, I want to build an image that would run my bash script when I start a container using that image. I already saw What is the difference between CMD and ENTRYPOINT in a Dockerfile? but I’m still left confused on how to properly use these two directives.