sumedhe
sumedhe

Reputation: 1018

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.

Upvotes: 0

Views: 167

Answers (1)

danblack
danblack

Reputation: 14666

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

Upvotes: 2

Related Questions