Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[Fail]: Starting MySQL in my Ubuntu docker

Tags:

docker

mysql

FROM ubuntu

RUN apt-get update && \
    apt-get -y upgrade && \
    apt-get install -y mysql-server && \
    apt-get install -y mysql-client

Then, I started a container, and ran:

/etc/init.d/mysql restart

Unfortunately, it didn't work:

root@5e37c0985d07:/opt# /etc/init.d/mysql restart * Stopping MySQL database server mysqld
[ OK ] * Starting MySQL database server mysqld
No directory, logging in with HOME=/ [fail]

Please note No directory, logging in with HOME in the error message.

like image 240
SmallChess Avatar asked Dec 10 '25 17:12

SmallChess


2 Answers

Try usermod -d /var/lib/mysql mysql and then /etc/init.d/mysql restart

like image 90
Sergey Papyan Avatar answered Dec 12 '25 11:12

Sergey Papyan


Try First to create an empty directory "mysql" at the host machine and then run the container with this directory path bind to the container directory path. Ex: docker run -i -t -p "3306:3306" -v ${PWD}/mysql:/var/lib/mysql "docker-image"

like image 37
Jay Patel Avatar answered Dec 12 '25 11:12

Jay Patel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!