I am following the official tutorial of Docker.I typed the same code as the tutorial,but got an unexpected error as shown below.I checked the Dashboard and found the container had exited.The log is shown below,which was too complicated to understand for me.I wonder why this happens and how I can keep the container running without exiting unexpectedly. Screenshot of the tutorial Screenshot of the CMD error message The Dashboard Log of the container
Updated:I used docker run -d --network todo-app --network-alias mysql -v todo-mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=secret -e MYSQL_DATABASE=todos mysql:5.7
to successfully create the container.However,when I typeddocker exec -it <container-id> mysql -p
,I got an unexpected error.Error response from daemon: Container <container-id> is not running
.Above <container-id>
s were all substituted correctly.
CodePudding user response:
Reading your container logs, I spotted a line saying that the DB didn't shutdown correctly.
As a result the volume may have corrupted files? In your case the certificates.
Try clearing all data in the volume, destroy the container. And repeat the process from scratch