How do I create a mysql client docker container that executes a mysql script against another mysql server container? Which base container should I use?


You can really use many different base images. Which one you use only changes how to install mysql client.

You could use debian like so

FROM debian
RUN apt-get update && \
    apt-get install -y mysql-client
CMD mysql {mysql-client-options} < {sql.script}

If using alpine, you just change the install to use apk instead

FROM alpine
RUN apk update && \
    apk add mysql-client
CMD mysql {mysql-client-options} < {sql.script}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.