search

Home  >  Q&A  >  body text

Dockerfile CMD does not support multiple commands for mysql image

Try running the mysql 5.7 image with the datadir flag and include the bash script in the CMD.

CMD ["--datadir=/data ; sh db_translations.sh"]

What ends up happening is that the container runs and creates a folder called data for mysql; sh db_translations.sh. Any idea why this is happening?

P粉217784586P粉217784586267 days ago458

reply all(1)I'll reply

  • P粉071743732

    P粉0717437322024-03-31 09:06:30

    While many containers treat bash /sh as ENTRYPOINT and this works, for mysql containers, >ENTRYPOINT Already a script, it will only accept the provided CMD and will not re-evaluate in script form.

    See using /docker-entrypoint-initdb.d as the script location for each document - https://hub.docker.com/_/mysql, although you may need Reorganized scripts and environments.

    reply
    0
  • Cancelreply