Skip to content

Cannot run container with random --user (5.7) #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tgerakitis opened this issue May 18, 2018 · 6 comments
Closed

Cannot run container with random --user (5.7) #430

tgerakitis opened this issue May 18, 2018 · 6 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@tgerakitis
Copy link

tgerakitis commented May 18, 2018

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?

@tianon
Copy link
Member

tianon commented May 18, 2018

I'm not sure what you're doing to create prefilledmysql:example, but you'll need to do something similar to what's done in #161 to your /var/lib/mysql2 to make that have even a remote chance of working (basically, what you're running into is very likely to be 100% standard unix filesystem permissions issues).

As for just running the existing image with an arbitrary UID, that's already supported (since #161), as long as the /var/lib/mysql permissions are set appropriately:

$ docker pull mysql:5.7
5.7: Pulling from library/mysql
Digest: sha256:f030e84582d939d313fe2ef469b5c65ffd0f7dff3b4b98e6ec9ae2dccd83dcdf
Status: Image is up to date for mysql:5.7

$ mkdir temp
$ sudo chown 1234:1234 temp
$ ls -ld temp
drwxr-xr-x 2 1234 1234 4096 May 18 10:12 temp

$ docker run -it --rm -e MYSQL_ROOT_PASSWORD=foobar --user 1234:1234 -v "$PWD/temp":/var/lib/mysql mysql:5.7
Initializing database
2018-05-18T17:13:30.482249Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-18T17:13:30.796840Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-05-18T17:13:30.840598Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-18T17:13:30.901800Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c9b2b283-5abe-11e8-8ac5-0242ac12001a.
2018-05-18T17:13:30.903698Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-18T17:13:30.905034Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2018-05-18T17:13:31.521929Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:31.521977Z 1 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:31.521994Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:31.522022Z 1 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:31.522033Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:31.522052Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:31.522119Z 1 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:31.522139Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
Database initialized
Initializing certificates
Generating a 2048 bit RSA private key
.................................+++
..............................+++
unable to write 'random state'
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
.................+++
.......................................+++
unable to write 'random state'
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
...................................+++
...........+++
unable to write 'random state'
writing new private key to 'client-key.pem'
-----
Certificates initialized
MySQL init process in progress...
2018-05-18T17:13:33.833603Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-18T17:13:33.834407Z 0 [Note] mysqld (mysqld 5.7.22) starting as process 75 ...
2018-05-18T17:13:33.836048Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-05-18T17:13:33.836059Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-18T17:13:33.836061Z 0 [Note] InnoDB: Uses event mutexes
2018-05-18T17:13:33.836064Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-18T17:13:33.836065Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-18T17:13:33.836067Z 0 [Note] InnoDB: Using Linux native AIO
2018-05-18T17:13:33.836184Z 0 [Note] InnoDB: Number of pools: 1
2018-05-18T17:13:33.836236Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-18T17:13:33.837104Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-18T17:13:33.840782Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-18T17:13:33.841859Z 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-18T17:13:33.852849Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-18T17:13:33.861872Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-18T17:13:33.861969Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-18T17:13:33.893591Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-18T17:13:33.894120Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-18T17:13:33.894130Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-18T17:13:33.894688Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 2589156
2018-05-18T17:13:33.894984Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-05-18T17:13:33.895251Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-05-18T17:13:33.895871Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180518 17:13:33
2018-05-18T17:13:33.898195Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-05-18T17:13:33.898373Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-18T17:13:33.901596Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2018-05-18T17:13:33.902121Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:33.902134Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:33.902140Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:33.902149Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:33.902152Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:33.902158Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:33.902800Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:33.902808Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:33.905933Z 0 [Note] Event Scheduler: Loaded 0 events
2018-05-18T17:13:33.906096Z 0 [Note] mysqld: ready for connections.
Version: '5.7.22'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2018-05-18T17:13:35.662845Z 4 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:35.662861Z 4 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:35.662869Z 4 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:35.662882Z 4 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:35.662886Z 4 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:35.662895Z 4 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:35.662926Z 4 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:35.662931Z 4 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.

2018-05-18T17:13:35.664005Z 0 [Note] Giving 0 client threads a chance to die gracefully
2018-05-18T17:13:35.664015Z 0 [Note] Shutting down slave threads
2018-05-18T17:13:35.664019Z 0 [Note] Forcefully disconnecting 0 remaining clients
2018-05-18T17:13:35.664042Z 0 [Note] Event Scheduler: Purging the queue. 0 events
2018-05-18T17:13:35.664297Z 0 [Note] Binlog end
2018-05-18T17:13:35.664600Z 0 [Note] Shutting down plugin 'ngram'
2018-05-18T17:13:35.664606Z 0 [Note] Shutting down plugin 'partition'
2018-05-18T17:13:35.664608Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2018-05-18T17:13:35.664611Z 0 [Note] Shutting down plugin 'ARCHIVE'
2018-05-18T17:13:35.664613Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2018-05-18T17:13:35.664626Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2018-05-18T17:13:35.664629Z 0 [Note] Shutting down plugin 'MyISAM'
2018-05-18T17:13:35.664633Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2018-05-18T17:13:35.664635Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2018-05-18T17:13:35.664637Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2018-05-18T17:13:35.664639Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2018-05-18T17:13:35.664642Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2018-05-18T17:13:35.664644Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2018-05-18T17:13:35.664647Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2018-05-18T17:13:35.664649Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2018-05-18T17:13:35.664651Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2018-05-18T17:13:35.664653Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2018-05-18T17:13:35.664655Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2018-05-18T17:13:35.664656Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2018-05-18T17:13:35.664658Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2018-05-18T17:13:35.664660Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2018-05-18T17:13:35.664679Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2018-05-18T17:13:35.664681Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2018-05-18T17:13:35.664683Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2018-05-18T17:13:35.664684Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2018-05-18T17:13:35.664704Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2018-05-18T17:13:35.664707Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2018-05-18T17:13:35.664710Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2018-05-18T17:13:35.664713Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2018-05-18T17:13:35.664716Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2018-05-18T17:13:35.664718Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2018-05-18T17:13:35.664721Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2018-05-18T17:13:35.664723Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2018-05-18T17:13:35.664726Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2018-05-18T17:13:35.664729Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2018-05-18T17:13:35.664731Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2018-05-18T17:13:35.664734Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2018-05-18T17:13:35.664737Z 0 [Note] Shutting down plugin 'InnoDB'
2018-05-18T17:13:35.664782Z 0 [Note] InnoDB: FTS optimize thread exiting.
2018-05-18T17:13:35.664836Z 0 [Note] InnoDB: Starting shutdown...
2018-05-18T17:13:35.765117Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2018-05-18T17:13:35.765733Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 180518 17:13:35
2018-05-18T17:13:36.876148Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12358623
2018-05-18T17:13:36.877709Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-05-18T17:13:36.877726Z 0 [Note] Shutting down plugin 'MEMORY'
2018-05-18T17:13:36.877730Z 0 [Note] Shutting down plugin 'CSV'
2018-05-18T17:13:36.877734Z 0 [Note] Shutting down plugin 'sha256_password'
2018-05-18T17:13:36.877737Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-05-18T17:13:36.877853Z 0 [Note] Shutting down plugin 'binlog'
2018-05-18T17:13:36.878244Z 0 [Note] mysqld: Shutdown complete


MySQL init process done. Ready for start up.

2018-05-18T17:13:37.094039Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-18T17:13:37.094848Z 0 [Note] mysqld (mysqld 5.7.22) starting as process 1 ...
2018-05-18T17:13:37.096476Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-05-18T17:13:37.096487Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-18T17:13:37.096489Z 0 [Note] InnoDB: Uses event mutexes
2018-05-18T17:13:37.096491Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-05-18T17:13:37.096493Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-18T17:13:37.096495Z 0 [Note] InnoDB: Using Linux native AIO
2018-05-18T17:13:37.096660Z 0 [Note] InnoDB: Number of pools: 1
2018-05-18T17:13:37.096764Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-05-18T17:13:37.097649Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-05-18T17:13:37.101423Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-05-18T17:13:37.102524Z 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-18T17:13:37.113490Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-18T17:13:37.118382Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-05-18T17:13:37.118422Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-05-18T17:13:37.144885Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-05-18T17:13:37.145227Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-05-18T17:13:37.145233Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-05-18T17:13:37.145683Z 0 [Note] InnoDB: 5.7.22 started; log sequence number 12358623
2018-05-18T17:13:37.145814Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-05-18T17:13:37.145944Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-05-18T17:13:37.147230Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180518 17:13:37
2018-05-18T17:13:37.147993Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2018-05-18T17:13:37.148106Z 0 [Warning] CA certificate ca.pem is self signed.
2018-05-18T17:13:37.149332Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2018-05-18T17:13:37.149350Z 0 [Note] IPv6 is available.
2018-05-18T17:13:37.149618Z 0 [Note]   - '::' resolves to '::';
2018-05-18T17:13:37.149628Z 0 [Note] Server socket created on IP: '::'.
2018-05-18T17:13:37.150902Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2018-05-18T17:13:37.151475Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:37.151488Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:37.151493Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:37.151504Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:37.151507Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:37.151513Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:37.152505Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:37.152513Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-05-18T17:13:37.155455Z 0 [Note] Event Scheduler: Loaded 0 events
2018-05-18T17:13:37.155597Z 0 [Note] mysqld: ready for connections.
Version: '5.7.22'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)

@tgerakitis
Copy link
Author

@tianon
The 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

@tianon
Copy link
Member

tianon commented May 18, 2018

In theory that might work, but I imagine there are probably parts of MySQL that don't enjoy having all files be 777 -- I know PostgreSQL is really picky about that, so it wouldn't surprise me if MySQL is too in some places (especially since it's generally a bad idea to do that for all files like this).

@tgerakitis
Copy link
Author

tgerakitis commented May 18, 2018

@tianon I know it is ugly but OpenShift needs to run as random user in my case (not my decision!)
I looked at the link you posted but was not able to find anything related to my problem, could you give me a hint at what I should be looking for?

The 777 seemed to only trouble MySQL with *.cnf files that is why there is this in the Dockerfile find /var/lib/mysql2/ -name "*.cnf" -exec chmod 775 {} \; && \
All I want is to get this to work. (I am getting quite desperate)

I also thought of copying the contents of /var/lib/mysql2 to /var/lib/mysql3 in entrypoint.sh before start of mysqld if it exists and using /var/libmysql3 which is 777 as DATADIR so permissions are ok for a random user coming from OpenShift.

The problem I have after running this is this error:

2018-05-18T17:27:08.069991Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table storage engine for 'user' doesn't have this option
2018-05-18T17:27:08.070212Z 0 [ERROR] Aborting

2018-05-18T17:27:08.070298Z 0 [Note] Binlog end
2018-05-18T17:27:08.070410Z 0 [Note] Shutting down plugin 'ngram'
2018-05-18T17:27:08.070439Z 0 [Note] Shutting down plugin 'partition'
2018-05-18T17:27:08.070443Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2018-05-18T17:27:08.070447Z 0 [Note] Shutting down plugin 'ARCHIVE'
2018-05-18T17:27:08.070450Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2018-05-18T17:27:08.070523Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2018-05-18T17:27:08.070530Z 0 [Note] Shutting down plugin 'MyISAM'
2018-05-18T17:27:08.070539Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2018-05-18T17:27:08.070543Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2018-05-18T17:27:08.070545Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2018-05-18T17:27:08.070548Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2018-05-18T17:27:08.070550Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2018-05-18T17:27:08.070553Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2018-05-18T17:27:08.070555Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2018-05-18T17:27:08.070557Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2018-05-18T17:27:08.070559Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2018-05-18T17:27:08.070562Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2018-05-18T17:27:08.070565Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2018-05-18T17:27:08.070567Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2018-05-18T17:27:08.070569Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2018-05-18T17:27:08.070572Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2018-05-18T17:27:08.070574Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2018-05-18T17:27:08.070596Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2018-05-18T17:27:08.070602Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2018-05-18T17:27:08.070605Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2018-05-18T17:27:08.070607Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2018-05-18T17:27:08.070610Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2018-05-18T17:27:08.070612Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2018-05-18T17:27:08.070615Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2018-05-18T17:27:08.070617Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2018-05-18T17:27:08.070620Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2018-05-18T17:27:08.070622Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2018-05-18T17:27:08.070624Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2018-05-18T17:27:08.070627Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2018-05-18T17:27:08.070629Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2018-05-18T17:27:08.070632Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2018-05-18T17:27:08.070634Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2018-05-18T17:27:08.070636Z 0 [Note] Shutting down plugin 'InnoDB'
2018-05-18T17:27:08.070798Z 0 [Note] InnoDB: FTS optimize thread exiting.
2018-05-18T17:27:08.071122Z 0 [Note] InnoDB: Starting shutdown...
2018-05-18T17:27:08.171456Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql2/ib_buffer_pool
2018-05-18T17:27:08.172002Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 180518 17:27:08
2018-05-18T17:27:09.689485Z 0 [Note] InnoDB: Shutdown completed; log sequence number 13341736
2018-05-18T17:27:09.694768Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2018-05-18T17:27:09.694836Z 0 [Note] Shutting down plugin 'MEMORY'
2018-05-18T17:27:09.694842Z 0 [Note] Shutting down plugin 'CSV'
2018-05-18T17:27:09.694846Z 0 [Note] Shutting down plugin 'sha256_password'
2018-05-18T17:27:09.694848Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-05-18T17:27:09.694975Z 0 [Note] Shutting down plugin 'binlog'
2018-05-18T17:27:09.698321Z 0 [Note] mysqld: Shutdown complete

@wglambert wglambert added the question Usability question, not directly related to an error with the image label May 21, 2018
@tianon
Copy link
Member

tianon commented Jul 9, 2018

Have you tried ditching the chown/chmod bits, doing the initialization in mysql2, then doing the copy to mysql3 at runtime? Does the random UID have enough permissions to at least read all the necessary files to make the copy? I wonder if there are any missing attributes that'd warrant installing rsync to ensure a more faithful copying.

@tgerakitis
Copy link
Author

The best way is to zip the files and extract them on runtime so the files have the correct owner as suggested on:
https://stackoverflow.com/questions/50397971/run-mysql-a-prefilled-docker-container-as-random-non-root-linux-user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants