Docker Community Forums

Share and learn in the Docker community.

Can't build container with mariadb

build

(Nikita Chernyi) #1

Issue type: Novice problem
Host OS: Ubuntu 16.04 x86_64
Docker OS: Alpine Linux Edge
Docker version: 1.11.0, build 4dc5990
MariaDB version: 10.1.13
All files (Dockerfile, my.cnf, startup.sh) and docker build . log are here: https://gist.github.com/rakshazi/1048c45ba7da181b9e87ed5ed4faef9b
Sorry, but new users can’t post more than 2 links in post

How can i fix this problem and run mariadb inside docker container?

pS: i’m novice with docker, please, be patient.


(Jeff Anderson) #2

Each RUN line in a Dockerfile gets executed as the only process in a container. The command you are running, mysql_install_db --verbose && /usr/bin/mysqladmin -u root password 'password', attempts to communicate with an already running mysql/mariadb server. Since this is the only thing running in the container, and there is no mysql service running, it fails.

Normally this sort of stuff should get run at runtime in an ENTRYPOINT script instead of at build time. This is because you’ll want your mysql/mariadb files to be stored in a volume and not in the layered filesystem.

Take a look at the official mysql and mariadb images as a starting point: https://github.com/docker-library/mariadb/tree/master/10.1 and https://github.com/docker-library/mysql/tree/master/5.7