{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/mysql/pulls/comments/37188425","id":37188425,"diff_hunk":"@@ -122,6 +122,172 @@ your container. This will allow you to login to the root account remotely. Local\n connections will still not require a password.\n \n \n+Extending the Docker image\n+--------------------------\n+\n+The Docker image provides reasonable set of features that should cover most of the use cases out or the box. For cases when some feature is missing, the image allows consumers to extend the functionality. \n+\n+Typically, these changes are: \n+\n+* editing other configuration options\n+* adjusting how the database is initialized during first start\n+* specifying what happens before every start of the database daemon\n+* creating more users or databases during database initialization\n+\n+There are basically two ways how to extend or change the image functionality:\n+\n+* by creating a new layered Docker image on top of this one, while using this image as base \n+* by volume mounting files during running the Docker image\n+\n+\n+Creating a new layered Docker image on top of this Docker image\n+---------------------------------------------------------------\n+In order to use this Docker image as base in other layered Docker image, specify name of this one as base and then add files or run commands as you need, like this:\n+```\n+FROM <this-image>\n+ADD mystuff /usr/bin/\n+RUN /usr/bin/mystuff\n+```\n+\n+### Example of adding a new configuration file in layered Dockerfile:\n+\n+To change configuration for the `mysqld` daemon and other utilities running within the container, place your new configuration files with `*.cnf` extention into `/etc/my.cnf.d` directory.\n+\n+Example of the layered Dockerfile:\n+\n+```\n+FROM <this-image>\n+ADD myconfig.cnf /etc/my.cnf.d/myconfig.cnf\n+```\n+\n+Notice: Read order of configuration files in `/etc/my.cnf.d/` directory is not specified.\n+\n+### Adjusting database inicialization\n+\n+Initialization of mysql database during first start of this image is devided into several files in several directories. All directories include files that are read in alphabetical order, and thus file names are usually prefixed with a number.\n+\n+Concretly there are these directories within the Docker container:\n+\n+* `/usr/share/container-layer/mysql/pre-init/` -- this directory includes shell scripts with extention `.sh` that will be sourced and thus executed before every inicialization of container (no matter whether the data directory is empty or not). At the time these scripts are executed, the daemon is not yet running. Example of script in this directory is a script that checks arguments specified by user.","path":"README.md","position":50,"original_position":50,"commit_id":"3aa41c8d2f7bea49bd8bb599d7d649a872c57675","original_commit_id":"3aa41c8d2f7bea49bd8bb599d7d649a872c57675","user":{"login":"hhorak","id":1405588,"avatar_url":"https://avatars.githubusercontent.com/u/1405588?v=3","gravatar_id":"","url":"https://api.github.com/users/hhorak","html_url":"https://github.com/hhorak","followers_url":"https://api.github.com/users/hhorak/followers","following_url":"https://api.github.com/users/hhorak/following{/other_user}","gists_url":"https://api.github.com/users/hhorak/gists{/gist_id}","starred_url":"https://api.github.com/users/hhorak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhorak/subscriptions","organizations_url":"https://api.github.com/users/hhorak/orgs","repos_url":"https://api.github.com/users/hhorak/repos","events_url":"https://api.github.com/users/hhorak/events{/privacy}","received_events_url":"https://api.github.com/users/hhorak/received_events","type":"User","site_admin":false},"body":"Maybe I don't understand the lifecycle hooks correctly, so I may just stop by to consult this magic feature.","created_at":"2015-08-17T13:46:06Z","updated_at":"2015-08-17T13:46:06Z","html_url":"https://github.com/openshift/mysql/pull/69#discussion_r37188425","pull_request_url":"https://api.github.com/repos/openshift/mysql/pulls/69","_links":{"self":{"href":"https://api.github.com/repos/openshift/mysql/pulls/comments/37188425"},"html":{"href":"https://github.com/openshift/mysql/pull/69#discussion_r37188425"},"pull_request":{"href":"https://api.github.com/repos/openshift/mysql/pulls/69"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/mysql/pulls/69","id":40583361,"html_url":"https://github.com/openshift/mysql/pull/69","diff_url":"https://github.com/openshift/mysql/pull/69.diff","patch_url":"https://github.com/openshift/mysql/pull/69.patch","issue_url":"https://api.github.com/repos/openshift/mysql/issues/69","number":69,"state":"open","locked":false,"title":"Refactoring scripts and making the image easily extensible","user":{"login":"hhorak","id":1405588,"avatar_url":"https://avatars.githubusercontent.com/u/1405588?v=3","gravatar_id":"","url":"https://api.github.com/users/hhorak","html_url":"https://github.com/hhorak","followers_url":"https://api.github.com/users/hhorak/followers","following_url":"https://api.github.com/users/hhorak/following{/other_user}","gists_url":"https://api.github.com/users/hhorak/gists{/gist_id}","starred_url":"https://api.github.com/users/hhorak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhorak/subscriptions","organizations_url":"https://api.github.com/users/hhorak/orgs","repos_url":"https://api.github.com/users/hhorak/repos","events_url":"https://api.github.com/users/hhorak/events{/privacy}","received_events_url":"https://api.github.com/users/hhorak/received_events","type":"User","site_admin":false},"body":"This is mostly a redesign of the scripts, while most changes were already consulted before, but never made it to these docker images so far.\r\n\r\nMost of the changes are transparent for the image users, while they are just re-organizing the scripts. The reason for the changes is to allow to extend images easier for user and also to make future maintenance simpler, since one complex bash script would be hard to change in another layer.\r\n\r\nThese are the changes made:\r\n* available commands (that are expected to be used as docker run argument) are now called `run-mysqld`, `run-mysqld-master`, `run-mysqld-slave` and those binaries are available under `/usr/bin`, so users may start them on demand, e.g. when debugging the image (if `run-mysqld-master.sh` or `mysqld-master` are already considered to be API, we can add those symlinks to not break depended stuff)\r\n* entrypoint script is now called `container-entrypoint`\r\n* the entrypoint now serves just for changing environment, nothing more\r\n* configuration files are located in the path that binaries expect (e.g. `/opt/rh/mysql55/root/etc/my.cnf`) and `/etc/my.cnf`, `/etc/my.cnf.d` are symlinks to those files, so users may work with `/etc/my.cnf` and `/etc/my.cnf.d` directly. As a result, `--defaults-file` doesn't have to be used when working with binaries\r\n* preparation of directories during build (fixing access) is now done by script `/usr/libexec/cont-setup`, so dockerfile is more clean\r\n* in configuration file, the `mysql` user is not specified, we want to let running daemon under actual user every-time\r\n* images are now more easily extensible, by dropping scripts with further initialization into expected directories (e.g. `/usr/share/cont-layer/mysql/post-init`)\r\n* scripts don't include collection name hard-coded, but the collection is specified in the Dockerfile and thus most of the scripts may be common for more versions of mysql (which makes maintenance easier)\r\n* `container-usage` returns help for the container","created_at":"2015-07-22T16:19:14Z","updated_at":"2015-08-17T13:46:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"47904437282854db6b6cffce969f09a1b617bb71","assignee":{"login":"mnagy","id":72469,"avatar_url":"https://avatars.githubusercontent.com/u/72469?v=3","gravatar_id":"","url":"https://api.github.com/users/mnagy","html_url":"https://github.com/mnagy","followers_url":"https://api.github.com/users/mnagy/followers","following_url":"https://api.github.com/users/mnagy/following{/other_user}","gists_url":"https://api.github.com/users/mnagy/gists{/gist_id}","starred_url":"https://api.github.com/users/mnagy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnagy/subscriptions","organizations_url":"https://api.github.com/users/mnagy/orgs","repos_url":"https://api.github.com/users/mnagy/repos","events_url":"https://api.github.com/users/mnagy/events{/privacy}","received_events_url":"https://api.github.com/users/mnagy/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/openshift/mysql/pulls/69/commits","review_comments_url":"https://api.github.com/repos/openshift/mysql/pulls/69/comments","review_comment_url":"https://api.github.com/repos/openshift/mysql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/mysql/issues/69/comments","statuses_url":"https://api.github.com/repos/openshift/mysql/statuses/3aa41c8d2f7bea49bd8bb599d7d649a872c57675","head":{"label":"hhorak:refactoring-scripts","ref":"refactoring-scripts","sha":"3aa41c8d2f7bea49bd8bb599d7d649a872c57675","user":{"login":"hhorak","id":1405588,"avatar_url":"https://avatars.githubusercontent.com/u/1405588?v=3","gravatar_id":"","url":"https://api.github.com/users/hhorak","html_url":"https://github.com/hhorak","followers_url":"https://api.github.com/users/hhorak/followers","following_url":"https://api.github.com/users/hhorak/following{/other_user}","gists_url":"https://api.github.com/users/hhorak/gists{/gist_id}","starred_url":"https://api.github.com/users/hhorak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhorak/subscriptions","organizations_url":"https://api.github.com/users/hhorak/orgs","repos_url":"https://api.github.com/users/hhorak/repos","events_url":"https://api.github.com/users/hhorak/events{/privacy}","received_events_url":"https://api.github.com/users/hhorak/received_events","type":"User","site_admin":false},"repo":{"id":33585528,"name":"mysql","full_name":"hhorak/mysql","owner":{"login":"hhorak","id":1405588,"avatar_url":"https://avatars.githubusercontent.com/u/1405588?v=3","gravatar_id":"","url":"https://api.github.com/users/hhorak","html_url":"https://github.com/hhorak","followers_url":"https://api.github.com/users/hhorak/followers","following_url":"https://api.github.com/users/hhorak/following{/other_user}","gists_url":"https://api.github.com/users/hhorak/gists{/gist_id}","starred_url":"https://api.github.com/users/hhorak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhorak/subscriptions","organizations_url":"https://api.github.com/users/hhorak/orgs","repos_url":"https://api.github.com/users/hhorak/repos","events_url":"https://api.github.com/users/hhorak/events{/privacy}","received_events_url":"https://api.github.com/users/hhorak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hhorak/mysql","description":"","fork":true,"url":"https://api.github.com/repos/hhorak/mysql","forks_url":"https://api.github.com/repos/hhorak/mysql/forks","keys_url":"https://api.github.com/repos/hhorak/mysql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hhorak/mysql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hhorak/mysql/teams","hooks_url":"https://api.github.com/repos/hhorak/mysql/hooks","issue_events_url":"https://api.github.com/repos/hhorak/mysql/issues/events{/number}","events_url":"https://api.github.com/repos/hhorak/mysql/events","assignees_url":"https://api.github.com/repos/hhorak/mysql/assignees{/user}","branches_url":"https://api.github.com/repos/hhorak/mysql/branches{/branch}","tags_url":"https://api.github.com/repos/hhorak/mysql/tags","blobs_url":"https://api.github.com/repos/hhorak/mysql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hhorak/mysql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hhorak/mysql/git/refs{/sha}","trees_url":"https://api.github.com/repos/hhorak/mysql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hhorak/mysql/statuses/{sha}","languages_url":"https://api.github.com/repos/hhorak/mysql/languages","stargazers_url":"https://api.github.com/repos/hhorak/mysql/stargazers","contributors_url":"https://api.github.com/repos/hhorak/mysql/contributors","subscribers_url":"https://api.github.com/repos/hhorak/mysql/subscribers","subscription_url":"https://api.github.com/repos/hhorak/mysql/subscription","commits_url":"https://api.github.com/repos/hhorak/mysql/commits{/sha}","git_commits_url":"https://api.github.com/repos/hhorak/mysql/git/commits{/sha}","comments_url":"https://api.github.com/repos/hhorak/mysql/comments{/number}","issue_comment_url":"https://api.github.com/repos/hhorak/mysql/issues/comments{/number}","contents_url":"https://api.github.com/repos/hhorak/mysql/contents/{+path}","compare_url":"https://api.github.com/repos/hhorak/mysql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hhorak/mysql/merges","archive_url":"https://api.github.com/repos/hhorak/mysql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hhorak/mysql/downloads","issues_url":"https://api.github.com/repos/hhorak/mysql/issues{/number}","pulls_url":"https://api.github.com/repos/hhorak/mysql/pulls{/number}","milestones_url":"https://api.github.com/repos/hhorak/mysql/milestones{/number}","notifications_url":"https://api.github.com/repos/hhorak/mysql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hhorak/mysql/labels{/name}","releases_url":"https://api.github.com/repos/hhorak/mysql/releases{/id}","created_at":"2015-04-08T04:53:04Z","updated_at":"2015-04-08T04:53:04Z","pushed_at":"2015-08-17T10:26:13Z","git_url":"git://github.com/hhorak/mysql.git","ssh_url":"git@github.com:hhorak/mysql.git","clone_url":"https://github.com/hhorak/mysql.git","svn_url":"https://github.com/hhorak/mysql","homepage":null,"size":261,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"bc9a8c6edd593e5df23b5a3303449eec954635ef","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":31020442,"name":"mysql","full_name":"openshift/mysql","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/mysql","description":"","fork":false,"url":"https://api.github.com/repos/openshift/mysql","forks_url":"https://api.github.com/repos/openshift/mysql/forks","keys_url":"https://api.github.com/repos/openshift/mysql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/mysql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/mysql/teams","hooks_url":"https://api.github.com/repos/openshift/mysql/hooks","issue_events_url":"https://api.github.com/repos/openshift/mysql/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/mysql/events","assignees_url":"https://api.github.com/repos/openshift/mysql/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/mysql/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/mysql/tags","blobs_url":"https://api.github.com/repos/openshift/mysql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/mysql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/mysql/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/mysql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/mysql/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/mysql/languages","stargazers_url":"https://api.github.com/repos/openshift/mysql/stargazers","contributors_url":"https://api.github.com/repos/openshift/mysql/contributors","subscribers_url":"https://api.github.com/repos/openshift/mysql/subscribers","subscription_url":"https://api.github.com/repos/openshift/mysql/subscription","commits_url":"https://api.github.com/repos/openshift/mysql/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/mysql/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/mysql/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/mysql/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/mysql/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/mysql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/mysql/merges","archive_url":"https://api.github.com/repos/openshift/mysql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/mysql/downloads","issues_url":"https://api.github.com/repos/openshift/mysql/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/mysql/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/mysql/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/mysql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/mysql/labels{/name}","releases_url":"https://api.github.com/repos/openshift/mysql/releases{/id}","created_at":"2015-02-19T15:03:58Z","updated_at":"2015-08-13T08:09:02Z","pushed_at":"2015-08-14T07:36:39Z","git_url":"git://github.com/openshift/mysql.git","ssh_url":"git@github.com:openshift/mysql.git","clone_url":"https://github.com/openshift/mysql.git","svn_url":"https://github.com/openshift/mysql","homepage":null,"size":751,"stargazers_count":10,"watchers_count":10,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":5,"forks":18,"open_issues":5,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/mysql/pulls/69"},"html":{"href":"https://github.com/openshift/mysql/pull/69"},"issue":{"href":"https://api.github.com/repos/openshift/mysql/issues/69"},"comments":{"href":"https://api.github.com/repos/openshift/mysql/issues/69/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/mysql/pulls/69/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/mysql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/mysql/pulls/69/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/mysql/statuses/3aa41c8d2f7bea49bd8bb599d7d649a872c57675"}}}}