Wordpress: ZipArchive is missing

Created on 28 Mar 2017  路  17Comments  路  Source: docker-library/wordpress

Hi,

does it make sense to deploy is the ZipArchive in the image?

BR,
Alex

Most helpful comment

If you have a running container and would like to enable ZipArchive, you can bash into it and then running the commands suggested previously

docker exec -it <container_name> /bin/bash
apt-get update &&  apt-get install -y zlib1g-dev
docker-php-ext-install zip
/etc/init.d/apache2 reload

you must reload apache configuration which is done by the last command.

This way I was able to use duplicator plugin successfully.

All 17 comments

It makes a great deal of sense because it is a prerequisite for all the useful backup plugins amongst other things. Forgetting to deploy ZipArchive was a major oversight!

I second that. Having ZipArchive enabled by default would be a must. So many plugins are using it!

Ditto.

Very useful to have ZipArchive. Tried to create an image from wordpress using the following Dockerfile but did not work (any suggestions are welcome).

FROM wordpress:latest
RUN apt-get update && apt-get install -y libz-dev && pecl install zlib zip
EXPOSE 80

I managed to do it with
RUN apt-get install -y zlib1g-dev && rm -rf /var/lib/apt/lists/* && docker-php-ext-install zip
Please check my Dockerfile at https://github.com/kirlat/docker-wp-dev-blaze-edition/blob/master/Dockerfile. It has a bunch of other staff for Xdebug and WP CLI, and is based on wordpress:php7.1-apache but I believe the command above should work the same for any WP image variation.

Please let me know if you'll have any questions. I will be glad to help!

I am a newbie who is using docker-compose. The syntax for docker-compose is different from a normal dockerfile. Can instructions be given for how to update a running docker image? I would really prefer not to have to build my wordpress from scratch again just because I wanted to enable ZipArchive for Duplicator.

Hi @erowley! Sorry for a late response, was extremely busy with work. I'm not 100% sure what do you mean by saying that you want to "to update a running docker image". Do you want to modify docker-compose.yml to include ZipArchive into it? Sorry, but this is not possible.

The only way to solve this I know of is to build a new image that will include ZipArchive. Luckily, you can base it on a WordPress image and add commands that will install any additional elements you want (i.e. ZipArchive). Would it work for you?

If it will, then you can create a Dockerfile with the following:
`FROM wordpress:latest

RUN apt-get update \
&& apt-get install -y --force-yes --no-install-recommends less libxml2-dev \
&& docker-php-ext-install soap \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get install -y zlib1g-dev \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install zip`
and build an image from it.

Sorry, I'm a newbie to Docker, but was able to build an image with ZipArchive (and Xdebug with WP-CLI) for my own needs so I can share my experience, if that'll be helpful.

How can we incorporate the same process of commands through a docker-compose yml file?

You can't, these modifications have to be made in the Dockerfile.

Then what are the proper steps for installing wordpress, mysql and enabling php zip archiving in docker? My wordpress container has a required package that needs php zip archiving enabled. Please help!

@kirlat already described those steps and said that's not doable with a docker-compose.yml file.

Again : you'll have to create a file named Dockerfile that use the official wordpress image in its FROM statment (as suggested on the official image readme)

FROM wordpress:latest

RUN apt-get update \
    && apt-get install -y zlib1g-dev \
    && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-install zip 

The RUN statement:

  • update apt package list
  • install zip's dependency zlib1g-dev with apt
  • remove the apt package list to reclaim space
  • install the zip php extension with docker-php-ext-install

When you have your modified Dockerfile, either your build your Wordpress image from it with docker build -t blackhawk/wordpress . and then use blackhawk/wordpress in the docker-compose.yml file instead of the official image, or you have docker compose build it.

If you're not going to modify your Dockerfile often, you don't really need to build it with docker compose.

After that the instructions are the same than those for the official image.

Bottom line is you'll need a custom Dockerfile based on the official image and to build it a at some point.

Bottom line is you'll need a custom Dockerfile based on the official image and to build it a at some point.

This is spot on; thanks for the excellent summary and example Dockerfile, @buchdag. :heart:
(https://github.com/docker-library/wordpress/issues/213#issuecomment-337260184)

While needing the zip extension installed may be common, it's not _required_ for all users (or even any of the functionality in the default install, as far as I'm aware), and thus is outside the scope of the official image (if we were to expand the scope to include "commonly necessary modules", that becomes a slippery slope, since I'm not aware of an accepted authority we could point to for which modules are actually "commonly necessary"). Thanks!

Please forgive me for asking until I understood it. The solution does work and also opens my eyes to seeing how Dockerfile can run actions on initial images to form custom images. Thank you Thank you Thank you

If you have a running container and would like to enable ZipArchive, you can bash into it and then running the commands suggested previously

docker exec -it <container_name> /bin/bash
apt-get update &&  apt-get install -y zlib1g-dev
docker-php-ext-install zip
/etc/init.d/apache2 reload

you must reload apache configuration which is done by the last command.

This way I was able to use duplicator plugin successfully.

thanks! @cirovladimir works like a charm

If anyone is getting /bin/sh: apt-get: not found, you need to switch the update/install to use apk. This worked for me:

# Make sure we can add packages
USER root

# Update and install, similar to the above but different command and package names
RUN apk update \
    && apk add zlib-dev \
    && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-install zip

# Switch back to the right user to run the remaining commands in the Dockerfile
USER www-data

+1 for including this

Was this page helpful?
0 / 5 - 0 ratings