Giter VIP home page Giter VIP logo

Comments (5)

kk0501 avatar kk0501 commented on August 16, 2024

@horizon365

[Dockerfile]

FROM ubuntu:16.04
MAINTAINER xxx<xxxx>

RUN groupadd --gid 1000  -r mysql && useradd  --uid 1000 -r -g mysql mysql
RUN echo "deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse" >> /etc/apt/sources.list \
	&& echo "mysql-server mysql-server/root_password password root" | debconf-set-selections \
	&& echo "mysql-server mysql-server/root_password_again password root" | debconf-set-selections \
	&& apt-get update \
	&& apt-get -y install mysql-server-5.7  \
	&& mkdir -p /var/lib/mysql  \
	&& mkdir -p /var/run/mysqld  \
	&& mkdir -p /var/log/mysql  \
	&& chown -R mysql:mysql /var/lib/mysql  \
	&& chown -R mysql:mysql /var/run/mysqld  \
	&& chown -R mysql:mysql /var/log/mysql 

VOLUME /var/lib/mysql

COPY ./startup.sh /root/startup.sh

RUN chmod +x /root/startup.sh

ENTRYPOINT ["/root/startup.sh"]

EXPOSE 3306
CMD ["/usr/bin/mysqld_safe"]

[startup.sh]

#! /bin/bash
set -e

if [ ! -f /var/lib/mysql/ibdata1 ];then
	MYSQL_ROOT_PWD=${MYSQL_ROOT_PWD:-"mysql"}
	MYSQL_USER=${MYSQL_USER:-""}
	MYSQL_USER_PWD=${MYSQL_USER_PWD:-""}
	MYSQL_USER_DB=${MYSQL_USER_DB:-""}
	mysqld --initialize-insecure --user=mysql
	service mysql start $ sleep 10

	echo "[i] Setting root new password."
	mysql --user=root -e "UPDATE mysql.user set authentication_string=password('$MYSQL_ROOT_PWD') where user='root'; FLUSH PRIVILEGES;"

	echo "[i] Setting root remote password."
	mysql --user=root --password=$MYSQL_ROOT_PWD -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PWD' WITH GRANT OPTION; FLUSH PRIVILEGES;"
	
	echo "[i] Setting up new power user credentials."

	if [ -n "$MYSQL_USER_DB" ]; then
		echo "[i] Creating datebase: $MYSQL_USER_DB"
		mysql --user=root --password=$MYSQL_ROOT_PWD -e "CREATE DATABASE IF NOT EXISTS \`$MYSQL_USER_DB\` CHARACTER SET utf8 COLLATE utf8_general_ci; FLUSH PRIVILEGES;"

		if [ -n "$MYSQL_USER" ] && [ -n "$MYSQL_USER_PWD" ]; then
			echo "[i] Create new User: $MYSQL_USER with password $MYSQL_USER_PWD for new database $MYSQL_USER_DB."
			mysql --user=root --password=$MYSQL_ROOT_PWD -e "GRANT ALL PRIVILEGES ON \`$MYSQL_USER_DB\`.* TO '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_USER_PWD' WITH GRANT OPTION; FLUSH PRIVILEGES;"
		else
			echo "[i] Don\`t need to create new User."
		fi
	else
		if [ -n "$MYSQL_USER" ] && [ -n "$MYSQL_USER_PWD" ]; then
			echo "[i] Create new User: $MYSQL_USER with password $MYSQL_USER_PWD for all database."
			mysql --user=root --password=$MYSQL_ROOT_PWD -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_USER_PWD' WITH GRANT OPTION; FLUSH PRIVILEGES;"
		else
			echo "[i] Don\`t need to create new User."
		fi
	fi
	killall mysqld
	sleep 5

fi

echo "[i] Setting end,have fun."
exec "$@"


from ubuntu-mysql.

dpalic avatar dpalic commented on August 16, 2024

even if the issue description is pretty emtpy, I am having also the exact same behaviour. My docker container exists after a short period

from ubuntu-mysql.

Isengo1989 avatar Isengo1989 commented on August 16, 2024

Same here

from ubuntu-mysql.

s-edlund avatar s-edlund commented on August 16, 2024

Here as well

from ubuntu-mysql.

biocrypto730 avatar biocrypto730 commented on August 16, 2024
git clone https://github.com/Leafney/ubuntu-mysql.git; 
cd ubuntu*; 
git pull origin pull/3/head; 

from ubuntu-mysql.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.