Home > Mobile >  [Solve]convert .zip into tar.gz inside dockerfile
[Solve]convert .zip into tar.gz inside dockerfile

Time:10-28

I got dockerfile that download .zip folder, because the docker container doesn't have apt-get. I cannot unzip it, but it seems that .tar.gz convert is embendded in dockerfile.

How do i convert .zip into .tar.gz in dockerfile?

is there any alternative? gunzip doesn't work either.

somezipfile.zip has more than one entry -- unchanged

The Part of Dockerfile

RUN curl -LJO http://somelink.com/verynew_python.zip

RUN gunzip -S .zip verynew_python.zip
ADD verynew_python.tar.gz /usr/bin
RUN chmod  x  /usr/bin/verynew_python/bin/python3.7

sorry i cannot post all dockerfile, but this is the part that important. i want to make python3.7 as main python.. there is no wget either.

CodePudding user response:

You can install packages in your docker containers - if you are free to choose something like this works:

RUN apk add --no-cache unzip

WORKDIR /tmp
COPY testfile.zip .
RUN unzip testfile.zip
RUN rm testfile.zip
RUN tar czvf testfile.tgz *

This results in:

$ docker run -ti x sh
/tmp # ls
testfile      testfile.tgz
/tmp #

This is quite inelegant but works. If your base image is from docker hub you can lookup if it is build on a distro and if yes which one it was and choose the "right" package manager for it - most often apk, yum or apt.

Keep in mind that - to keep images small - package caches are often not available and you need to fetch them like apt update or must use a non caching method like above.

CodePudding user response:

Does your docker container have wget ? You could have downloaded the unzip then and run it!

  • Related