Unable to use sed to customize buffer size in mariadb Dockerfile Unable to use sed to customize buffer size in mariadb Dockerfile docker docker

Unable to use sed to customize buffer size in mariadb Dockerfile


Just don't escape the spaces like you do:

  1. spaces don't need escaping
  2. escaping with \\ inside simple quotes actually create a \ char. No wonder why your regex doesn't work.

That works:

sed -i 's/innodb_buffer_pool_size = 256M/innodb_buffer_pool_size = 512M/g' /etc/mysql/my.cnf
  1. if you really have to escape something, that will be only because of regex, not the shell, because you have used simple quotes and the shell does not interpret the contents
  2. you don't need the -r, --regexp-extended switch for this particular example. regexp extended includes stuff like forward lookup, ... not needed here.

Improvement: use group to recall the matched value. Less maintenance if you have to change the parameter name

sed -i 's/\(innodb_buffer_pool_size\) = 256M/\1 = 512M/g' /etc/mysql/my.cnf

or match several parameter names

sed -i 's/\(innodb_buffer_pool_size\|some_other_param\) = 256M/\1 = 512M/g' /etc/mysql/my.cnf