Closed
Description
This image does not work with a prefilled container in OpenShift. (datadir=/var/lib/mysql2)
Dockerfile for prefilledmysql:example
FROM mysql:5.7.22
#IMPORTANT: MySQL Container runs init in alphanumerical order!
COPY src/*.sql /docker-entrypoint-initdb.d/
ENV MYSQL_ROOT_PASSWORD='somepw'
RUN mkdir -p /var/lib/mysql2 && \
chown -R mysql:mysql /var/lib/mysql2 && \
chmod -R 777 /var/lib/mysql2 && \
sed -i 's|/var/lib/mysql|/var/lib/mysql2|g' /etc/mysql/mysql.conf.d/mysqld.cnf && \
sed -i 's|exec "$@"||g' /entrypoint.sh && \
/entrypoint.sh mysqld && \
chmod -R 777 /var/lib/mysql2/ && \
chown -R mysql:mysql /var/lib/mysql2 && \
find /var/lib/mysql2/ -name "*.cnf" -exec chmod 775 {} \; && \
echo 'exec "$@"' >> /entrypoint.sh
(I also thought about creating a multi stage build - I thought that might drop any problems connected with users)
docker run --user 123456789 prefilledmysql:example
results in
2018-05-18T10:08:37.934520Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-18T10:08:37.934630Z 0 [Warning] Can't create test file /var/lib/mysql2/06d4631de9e3.lower-test
2018-05-18T10:08:37.934663Z 0 [Note] mysqld (mysqld 5.7.22) starting as process 1 ...
2018-05-18T10:08:37.936808Z 0 [Warning] Can't create test file /var/lib/mysql2/06d4631de9e3.lower-test
2018-05-18T10:08:37.936830Z 0 [Warning] Can't create test file /var/lib/mysql2/06d4631de9e3.lower-test
2018-05-18T10:08:37.938393Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-05-18T10:08:37.938454Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-18T10:08:37.938460Z 0 [Note] InnoDB: Uses event mutexes
2018-05-18T10:08:37.938464Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-18T10:08:37.938468Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-18T10:08:37.938471Z 0 [Note] InnoDB: Using Linux native AIO
2018-05-18T10:08:37.938803Z 0 [Note] InnoDB: Number of pools: 1
2018-05-18T10:08:37.939024Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-18T10:08:37.941552Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-18T10:08:37.948263Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-18T10:08:37.950175Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-05-18T10:08:37.960912Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2018-05-18T10:08:37.960983Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable
2018-05-18T10:08:37.960997Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-05-18T10:08:38.562655Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2018-05-18T10:08:38.562715Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2018-05-18T10:08:38.562721Z 0 [ERROR] Failed to initialize builtin plugins.
2018-05-18T10:08:38.562724Z 0 [ERROR] Aborting
2018-05-18T10:08:38.562728Z 0 [Note] Binlog end
2018-05-18T10:08:38.562824Z 0 [Note] Shutting down plugin 'CSV'
2018-05-18T10:08:38.568758Z 0 [Note] mysqld: Shutdown complete
Is there any way to get this to work with a random UID when starting the container?