dockerコンテナ内のファイルを変更する


mysqlを例に
 
MySQLプロファイルを変更するには、次の2つの方法があります.
  • はコンテナに入り、コンテナ内のMySQLのプロファイルを変更し、コンテナを再起動します.たとえば、
    $ sudo docker exec -it pwc-mysql /usr/bin/bash
    はコンテナのコマンドラインモードに入り、/etc/mysql/my.cnfファイルを変更すれば
  • になります.
  • はホストをマウントするmysqlプロファイルで、公式ドキュメントは以下の通りである:The MySQL startup configuration is specified in the file /etc/mysql/my.cnf、and that file in turn includes any files found in the /etc/mysql/conf.d directory that end with.cnf. Settings in files in this directory will augment and/or override settings in  /etc/mysql/my.cnf . If you want to use a customized MySQL configuration, you can create your alternative configuration file in a directory on the host machine and then mount that directory location as  /etc/mysql/conf.d  inside the mysql container. If  /my/custom/config-file.cnf  is the path and name of your custom configuration file, you can start your mysql container like this (note that only the directory path of the custom config file is used in this command):
    $ docker run --name some-mysql -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
    This will start a new container some-mysql where the MySQL instance uses the combined startup settings from  /etc/mysql/my.cnf  and  /etc/mysql/conf.d/config-file.cnf , with settings from the latter taking precedence.