How to modify docker php.ini without installing editor

Editor Not found

Recently I would like edit the php.ini in Bitnami WordPress Docker using CLI, but inside the docker doesn’t contain any editor and apt-get is not allowed me to install any editor.

$ vim
/bin/sh: 1: vim: not found
$ vi
/bin/sh: 2: vi: not found
$ nano
/bin/sh: 3: nano: not found
$ 

Modify the upload limit for PHP

I want to upload a file more than 800M, I’ve to apply these to php.ini

upload_max_filesize 1000M
post_max_size 1000M
memory_limit 1000M
max_execution_time 0
max_input_time 0

Solution I used

Get the docker CONTAINER ID

docker ps 
CONTAINER ID   IMAGE                       COMMAND                  CREATED        STATUS        PORTS                                         NAMES
aa63a037c4bb   bitnami/wordpress-nginx:5   "/opt/bitnami/script…"   18 hours ago   Up 18 hours   0.0.0.0:80->8080/tcp, 0.0.0.0:443->8443/tcp   wp-wordpress-1

Copy the php from the container to local directory

docker cp aa63a037c4bb:/opt/bitnami/php/etc/php.ini ./php.ini

Modify using your favorite editor, personally I like to use vim.

vim ./php.ini

After modified then upload and replace to the container

docker cp ./php.ini aa63a037c4bb:/opt/bitnami/php/etc/php.ini 

Restart your container.

Tags:

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.