简体   繁体   中英

How to start a mysql docker container with a dump.sql file in a single command without using docker-compose

I need to start a mysql docker container with an initial dump file or create a mysql docker image with initial data. I don't need to start docker container first and then execute with the dump file in separate commands. I need to run it using a single command.

So assuming the data contains your sql dump file:

docker run -v "$PWD/data":/docker-entrypoint-initdb.d \
  --user 1000:1000 \
  --name some-mysql \
  -e MYSQL_ROOT_PASSWORD=my-secret-pw \
  -d \
   mysql:tag

ref: hub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM