Dockerhub mysql install in ubuntu

I am installing mysql from docker hub.

---- code ----
sudo docker run -d -p 9876:3306 -e MYSQL_ROOT_PASSWORD=password mysql:5.6
---- /code ----

Installation went well,
In a minute, the status changes to Exited(1).
Why is it changing?
How do I keep it from changing?

Any help would be appreciated.

MySQL takes several minutes to start-up the first time since it must initialize the database. I suspect it also restarts during that time which could cause some issues for Docker.

I’d recommend using -it to keep the container running and mounting a persistent volume so subsequent start-ups take a couple of seconds:

docker run \
  -it --rm --name mysql \
  -p 9876:3306 \
  --mount "src=mysqldata,target=/var/lib/mysql" \
  -e MYSQL_ROOT_PASSWORD=password \
  mysql:5.6