So this is my Dockerfile,
FROM mariadb:10.3.5
RUN apt-get update & apt-get upgrade -y
ENV MYSQL_USER=user1 \
MYSQL_USER_PASSWORD=pass5 \
MYSQL_DATABASE=db \
MYSQL_ROOT_PASSWORD=XXX
ADD . /
WORKDIR /
However, this does not add my user1 to the database build. The root password works but that is it. I have completely removed all the pass tests i have done, including all volume data but still does not add the user. So what am I doing wrong?
Thanks,
Execute the following to connect to MariaDB using the command-line client: > docker exec -it mdb mariadb --user root -pPassword123! And that's it! That's all you need to connect to and start using (querying) MariaDB.
Official mariadb docker image has built-in enviromental variables MYSQL_USER
and MYSQL_PASSWORD
:
These variables are optional, used in conjunction to create a new user and to set that user's password. This user will be granted superuser permissions (see above) for the database specified by the MYSQL_DATABASE variable. Both variables are required for a user to be created.
So, the variable MYSQL_PASSWORD
was misspelled (it was defined as MYSQL_USER_PASSWORD
) and that's why mysql user was not created at all.
The correct Dockerfile
is:
FROM mariadb:10.3.5
RUN apt-get update & apt-get upgrade -y
ENV MYSQL_USER=user1 \
MYSQL_PASSWORD=pass5 \
MYSQL_DATABASE=db \
MYSQL_ROOT_PASSWORD=XXX
ADD . /
WORKDIR /
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With