title: My mysql docker container keeps exiting after running exec command
body: <p>I am using a script that I made to ease things on my docker. The script basically is</p>
  <pre><code>docker run -dit -e MYSQL_ROOT_PASSWORD=user123 --name lar -p 3306:3306 mysql:5.7
  </code></pre>
  <p>This one creates a docker container with the name <em>lar</em>.</p>
  <hr />
  <p>The other script to create a database in my container is:</p>
  <pre><code>echo &quot;Enter database name to create: &quot;
  read dbName
  mysqlScript=&quot;CREATE DATABASE $dbName;&quot;
  echo &quot;Running script $mysqlScript&quot;
  docker exec -i lar mysql -uroot -puser123 &lt;&lt;&lt; $mysqlScript
  </code></pre>
  <p>They both worked perfectly when I was using them on windows WSL but now there seems to be some trouble. Whenever I try to run the <code>createDB.sh</code> file, the container suddenly stops. Its not only for script file but whenever I try to manually exec into the container, the container goes down.</p>
  <p>this is the log</p>
  <pre><code>2022-05-01 16:19:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.38-1debian10 started.
  </code></pre>
  <hr />
  <p>And anytime I restart the container and repeat the same process, the same thing happens.</p>
  <hr />
  <p>Checked links:
  <a href="https://stackoverflow.com/questions/43308319/how-can-i-run-bash-in-a-new-container-of-a-docker-image">How can I run bash in a new container of a docker image?</a></p>
  <p><a href="https://stackoverflow.com/questions/66114411/docker-run-exited-right-away">docker run exited right away?</a></p>
  <hr />
  <p>If anyone wants to check out the actual script files:
  <a href="https://github.com/sugamkarki/docker-scripts/tree/master/mysql" rel="nofollow noreferrer">https://github.com/sugamkarki/docker-scripts/tree/master/mysql</a></p>