You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
mysql/mysql-5.7.38/dockerfile.2image

48 lines
2.6 KiB

FROM ubuntu:20.10 as builder
MAINTAINER 1793360097@qq.com
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql && echo > /etc/apt/sources.list
COPY install-db.sh /usr/local/bin/
RUN bash /usr/local/bin/install-db.sh Modify_Source DB_Dependent
RUN bash /usr/local/bin/install-db.sh Install_Only_Database pwd \
&& rm -rf /usr/local/src/* \
&& rm -rf /usr/local/mysql/bin/{mysqltest_embedded,mysql_embedded,mysql_client_test_embedded} /usr/local/mysql/mysql-test
RUN mkdir -p /etc/mysql/conf.d/ && echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf \
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql/share /var/run/mysqld \
&& chown -R mysql:mysql /var/lib/mysql /var/run/mysqld \
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
&& chmod 1777 /var/run/mysqld /var/lib/mysql
FROM ubuntu:20.10
COPY --from=builder /usr/local/mysql/* /usr/local/mysql
RUN groupadd -r mysql && useradd -r -g mysql mysql && mkdir -p /var/lib/mysql/share /var/run/mysqld /docker-entrypoint-initdb.d && chown mysql:mysql -R /usr/local/mysql /var/lib/mysql /var/run/mysqld /docker-entrypoint-initdb.d
ENV MYSQL_MAJOR 5.7
ENV MYSQL_VERSION 5.7.38-ubuntu20.10
ENV GOSU_VERSION 1.14
RUN set -eux; \
# TODO find a better userspace architecture detection method than querying the kernel
arch="$(uname -m)"; \
case "$arch" in \
aarch64) gosuArch='arm64' ;; \
x86_64) gosuArch='amd64' ;; \
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
esac; \
curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \
curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
chmod +x /usr/local/bin/gosu; \
gosu --version; \
gosu nobody true
VOLUME /var/lib/mysql
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 3306 33060
CMD ["mysqld"]