├── .gitignore ├── LICENSE ├── docker-entrypoint.sh ├── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .DS_Store 3 | .settings/ 4 | target/ 5 | nohup.out 6 | tmp/ 7 | 8 | # Intellij 9 | *.iml 10 | .idea/ 11 | /out/ 12 | 13 | # Eclipse 14 | .classpath 15 | .project 16 | 17 | # Package Files 18 | *.jar 19 | *.war 20 | *.ear 21 | *.gz 22 | *.zip -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Valery Samovich 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ ! -d '/var/lib/mysql/mysql' -a "${1%_safe}" = 'mysqld' ]; then 5 | if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" ]; then 6 | echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set' 7 | echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?' 8 | exit 1 9 | fi 10 | 11 | mysql_install_db --user=mysql --datadir=/var/lib/mysql 12 | 13 | # These statements _must_ be on individual lines, and _must_ end with 14 | # semicolons (no line breaks or comments are permitted). 15 | # TODO proper SQL escaping on ALL the things D: 16 | TEMP_FILE='/tmp/mysql-first-time.sql' 17 | cat > "$TEMP_FILE" <<-EOSQL 18 | DELETE FROM mysql.user ; 19 | CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ; 20 | GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ; 21 | DROP DATABASE IF EXISTS test ; 22 | EOSQL 23 | 24 | if [ "$MYSQL_DATABASE" ]; then 25 | echo "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE ;" >> "$TEMP_FILE" 26 | fi 27 | 28 | if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then 29 | echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" >> "$TEMP_FILE" 30 | 31 | if [ "$MYSQL_DATABASE" ]; then 32 | echo "GRANT ALL ON $MYSQL_DATABASE.* TO '$MYSQL_USER'@'%' ;" >> "$TEMP_FILE" 33 | fi 34 | fi 35 | 36 | echo 'FLUSH PRIVILEGES ;' >> "$TEMP_FILE" 37 | 38 | set -- "$@" --init-file="$TEMP_FILE" 39 | fi 40 | 41 | chown -R mysql:mysql /var/lib/mysql 42 | exec "$@" 43 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:trusty 2 | 3 | RUN groupadd -r mysql && useradd -r -g mysql mysql 4 | 5 | RUN apt-get update && \ 6 | apt-get install -y curl binutils 7 | 8 | RUN gpg --keyserver pgp.mit.edu --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5 9 | 10 | RUN locale-gen en_US.UTF-8 &&\ 11 | update-locale 12 | 13 | ENV LANG en_US.UTF-8 14 | 15 | ENV LANGUAGE en_US:en 16 | 17 | ENV LC_ALL en_US.UTF-8 18 | 19 | RUN curl -SL "http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz" -o mysql.tar.gz && \ 20 | curl -SL "http://mysql.he.net/Downloads/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz.asc" -o mysql.tar.gz.asc && \ 21 | gpg --verify mysql.tar.gz.asc && \ 22 | mkdir /usr/local/mysql && \ 23 | tar -xzf mysql.tar.gz -C /usr/local/mysql --strip-components=1 && \ 24 | rm mysql.tar.gz* && \ 25 | rm -rf /usr/local/mysql/mysql-test /usr/local/mysql/sql-bench && \ 26 | rm -rf /usr/local/mysql/bin/*-debug /usr/local/mysql/bin/*_embedded && \ 27 | find /usr/local/mysql -type f -name "*.a" -delete && \ 28 | { find /usr/local/mysql -type f -executable -exec strip --strip-all '{}' + || true; } && \ 29 | apt-get purge -y --auto-remove binutils && \ 30 | rm -rf /var/lib/apt/lists/* 31 | 32 | ENV PATH $PATH:/usr/local/mysql/bin:/usr/local/mysql/scripts 33 | 34 | WORKDIR /usr/local/mysql 35 | 36 | VOLUME /var/lib/mysql 37 | 38 | COPY docker-entrypoint.sh /entrypoint.sh 39 | 40 | ENTRYPOINT ["/entrypoint.sh"] 41 | 42 | EXPOSE 3306 43 | 44 | CMD ["mysqld", "--datadir=/var/lib/mysql", "--user=mysql"] 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mysql-5.1.73 [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](LICENSE) [![Docker Automated buil](https://img.shields.io/docker/automated/jrottenberg/ffmpeg.svg)](https://hub.docker.com/r/vsamov/mysql-5.1.73/) 2 | 3 | Docker image for MySQL 5.1.73 database based on official [MySQL](https://hub.docker.com/_/mysql/) image 4 | 5 | ## Installation 6 | 7 | - [Install Docker](https://docs.docker.com/engine/installation/) 8 | - Run docker commnad to get an image: `docker pull vsamov/mysql-5.1.73` 9 | - Validate image successfully downloaded: `docker images` 10 | 11 | ## Run 12 | 13 | Start a **mysql** server instance: 14 | 15 | # general form 16 | $ $ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...] 17 | 18 | # example 19 | $ docker run -d --name mysql-5.1.73 -p 3307:3306 -e MYSQL_ROOT_PASSWORD=[password] vsamov/mysql-5.1.73:latest 20 | 21 | ... where some-mysql is the name you want to assign to your container, my-secret-pw is the password to be set for the MySQL root user and tag is the tag specifying the MySQL version you want. See the list above for relevant tags. If port 3306 is used replace `-p 3306:3306` with `-p 3307:3306` 22 | 23 | Other **commands**: 24 | 25 | ## kill the container 26 | docker kill [container-id] 27 | 28 | # shell script/shell access 29 | $ docker exec -it vsamov/mysql-5.1.73:latest bash 30 | 31 | # viewing MySQL logs 32 | $ docker logs vsamov/mysql-5.1.73:latest 33 | 34 | # start exisitng container (often: after Docker Engine update) 35 | docker start [CONTAINER ID] 36 | 37 | ## Contribution 38 | 39 | Please contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a fork, add commits, and [open a pull request](https://github.com/fraction/readme-boilerplate/compare/). 40 | --------------------------------------------------------------------------------