Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker not unzipping my files

I have this simplified dockerfile, It should copy all the .zip files in plugins/ and then unzip them and so on.

The COPY command is working, but it's not getting unzipped, why?

FROM wordpress:4-fpm

# Install unzip
RUN apt-get update && apt-get install -y unzip

# Install zipped plugins, so that we don't have to manually install them.
WORKDIR /var/www/html/wp-content/plugins/
COPY ./plugins/*.zip ./
RUN unzip -q "*.zip"
RUN chown -R www-data:www-data .
RUN find . -name '*.zip' -delete

# Reset workdir
WORKDIR /var/www/html/

Update:

When I check the dir in the docker container docker exec -it theme_wordpress_1 bash

-rw-r----- 1      501 dialout  5.3K Nov 12 08:57 acf-to-wp-api.1.3.2.zip
-rw-r----- 1 root     root     1.1M Nov 12 08:52 advanced-custom-fields.4.4.3.zip
drwxr-xr-x 4 www-data www-data 4.0K Sep 15 14:58 akismet
-rw-r--r-- 1 www-data www-data 2.3K May 22  2013 hello.php
-rw-r--r-- 1 www-data www-data   28 Jun  5  2014 index.php
-rw-r----- 1 root     root     134K Nov 12 08:57 rest-api.2.0-beta5.zip

It looks a bit strange, even if the unzip didn't work, I think the chown would work, but instead the uploaded zip files are owned by root.

How is that possible?

like image 945
Leon Radley Avatar asked Oct 19 '22 22:10

Leon Radley


1 Answers

To avoid a wildcard (*) to be interpreted by the shell, try and wrap it in a command shell:

RUN sh -c 'unzip -q "*.zip"'
like image 86
VonC Avatar answered Oct 21 '22 21:10

VonC