Docker install MySQL database

 

Docker install MySQL database

Dockerfile

###### ###### ###### ###### ###### ###### ###### ## # version : birdben/ubuntu :mysql # desc : MySQL installed in the current version ###### ###### ###### ###### ###### ###### #### ## ## # The settings are inherited from the tools image we created FROM birdben/ ubuntu :tools # Below is some basic information about the creator MAINTAINER birdben ( 191654006 @ 163. com) # Set environment variables, all operations are non-interactive ENV DEBIAN_FRONTEND noninteractive # Add the supervisord configuration file and copy the configuration file to the corresponding directory. (supervisord.conf file and Dockerfile file are in the same path)COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf RUN echo "export LC_ALL=C" # Replace the sources.list file of the source server of the ubuntu software update COPY sources.list /etc/apt/sources.list # Install and upgrade gcc RUN sudo rm -rf /var/lib/apt/lists/ * RUN sudo apt-get update RUN sudo apt-get install -y make cmake gcc g++ bison libncurses5-dev build-essential # Copy mysql-5.6.22 file to the image (mysql-5.6.22 folder should be in the same path as the Dockerfile) ADD mysql- 5.6 .22 /software/downloads/mysql- 5.6 .22 RUN cd /software/downloads/mysql- 5.6 .22 && cmake . - DCMAKE_INSTALL_PREFIX =/software/mysql-5.6.22- DMYSQL_DATADIR =/software/mysql-5.6.22/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/software/mysql-5.6.22/mysql.sock -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DCOMPILATION_COMMENT="lq-edition" -DENABLE_DTRACE= 0 -DOPTIMIZER_TRACE= 1 -DWITH_DEBUG= 1 && make && make install # Add test user mysql, password mysql, and add this user to sudoers RUN useradd mysql RUN echo "mysql:mysql" | chpasswd RUN echo "mysql ALL=(ALL) ALL" >> /etc/sudoers # Set permissions for Mysql installation directory RUN cd /software/mysql-5.6.22 && sudo chown -R mysql:mysql ./ # Copy is ready COPY my.cnf file to Docker container my.cnf /etc/my.cnf RUN sudo chown mysql :mysql /etc/my.cnf # Initialize database RUN cd/software/mysql-5.6.22 && sudo ./scripts/mysql_install_db --user=mysql --basedir=/software/mysql-5.6.22 --datadir=/software/mysql-5.6.22/data/ # Set up MySQL If the reader has other environment variables to set, they can also add them here. ENV MYSQL_HOME /software/mysql- 5.6 .22 # (The following path is not recommended to be built directly on the Docker virtual machine, and volume mounting is recommended) # Create a database directory on the host to store Mysql data files # sudo mkdir - p /docker/mysql/data # The VOLUME option is to hang the local directory in the container. Note here: when you run -v <hostdir>:<Containerdir>, make sure that the content of the directory is the same, otherwise there will be data loss # Corresponding The relationship is as follows # mysql:/docker/mysql/data VOLUME [ "/software/mysql-5.6.22/data" ] # The container needs to open MySQL 3306 port EXPOSE 3306 # Execute supervisord to execute multiple commands at the same time, use supervisord's executable Path to start the service. CMD [ "/usr/bin/supervisord"]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326361604&siteId=291194637