在使用docker安裝wordpress時,如果在下完 docker compose up -d
後就馬上去瀏覽網頁
會發現顯示 Error establishing a database connection
一開始以為是docker compose 設定錯誤,後來搜尋後才發現這是因為container正在啟動中
因此只要稍等一下,等container完全啟動完畢就可以正常連線了
You are getting the errors because the WordPress container is trying to connect the MySQL database before it is ready and the user is created. if you give it some time after starting the services the user will be created and the WordPress will be able to access the database.