How to Install MySQL Client Inside Application Container

Sometimes we might feel the need to install MySQL client inside a Docker container which is running our application server. We might have faced some MySQL error while running some database query or there is some issue while connecting to MySQL server from the Docker container. At that time if we can install MySQL client inside Docker container, then we can directly check & debug MySQL related issues from the console. We use Alpine Linux as Docker container OS. Many people use that as it is very light weight. We can run below command to start an interactive shell inside a Docker container:

docker exec -it <container_name> /bin/bash 

Then we can execute below command to install MySQL client inside the container:

apk add mysql-client

That's it. MySQL client is installed now. You can use "mysql" command from the same interactive console & debug your issues.

Comments