Reputation: 1354
I input these commands on linux machine with docker installed:
(this approach is not what most people choose to run mysql in docker)
docker container run -it -d --restart always -p 4100:80 --name myapp ubuntu:22.04
docker exec -it --user=root myapp /bin/bash
apt update
apt install mysql-server
apt install mysql-client
mysql -v
I got this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
What do I need to do to fix or run mysql inside a ubuntu(or any distro) container, so any script(php/python) inside same ubuntu container can connect to mysql database?
Thanks in advance
Upvotes: 0
Views: 909
Reputation: 21
I think you forgot to put the password and the root user when you are running the container
for example :
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
anyways with the following link I could use MySQL image and make a container from it I hope that you will find this answer useful
Upvotes: 1