I am using a script that I made to ease things on my docker. The script basically is
docker run -dit -e MYSQL_ROOT_PASSWORD=user123 --name lar -p 3306:3306 mysql:5.7
This one creates a docker container with the name lar.
The other script to create a database in my container is:
echo "Enter database name to create: "
read dbName
mysqlScript="CREATE DATABASE $dbName;"
echo "Running script $mysqlScript"
docker exec -i lar mysql -uroot -puser123 <<< $mysqlScript
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 createDB.sh 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.
this is the log
2022-05-01 16:19:17+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.38-1debian10 started.
And anytime I restart the container and repeat the same process, the same thing happens.
Checked links: How can I run bash in a new container of a docker image?
If anyone wants to check out the actual script files: https://github.com/sugamkarki/docker-scripts/tree/master/mysql
lar..shfile)? They should be set to linux line endings (lf).file mysql.shand I gotmysql.sh: Bourne-Again shell script, ASCII text executable. I am not sure if that was what you were askingnanoorvi? If you see something like^Mat the end of each line, then the problem is most probably related to line ending encoding.^Mthingies. When I was on widows, I had thebad interpreterissue and had useddos2unixto fix it. When that happened, the file totally refused to run but now the container is running and I can see it in thedocker ps.