Docker container not able to locate Zip packages?

Tried with this Dockerfile (your Dockerfile without what I told you in my previous comment):

FROM ubuntu:15.10
RUN  apt-get update -y && \
     apt-get upgrade -y && \
     apt-get dist-upgrade -y && \
     apt-get -y autoremove && \
     apt-get clean
RUN apt-get install -y p7zip \
    p7zip-full \
    unace \
    zip \
    unzip \
    xz-utils \
    sharutils \
    uudeview \
    mpack \
    arj \
    cabextract \
    file-roller \
    && rm -rf /var/lib/apt/lists/*

CMD ["bash"]

It works and it installs zip and p7zip

$ docker build -t mytest .
$ docker run -d -ti --name mytest mytest /bin/bash
$ docker exec -ti mytest /bin/bash

 root@f01fc3456a2a:/# zip 
 root@f01fc3456a2a:/# p7zip

According to Docker best practices

@gile's answer could be improved by:

  • using apt-get update and install in a single layer
  • avoiding apt-get upgrade

https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#leverage-build-cache

Docker sees the initial and modified instructions as identical and reuses the cache from previous steps. As a result the apt-get update is not executed because the build uses the cached version. Because the apt-get update is not run, your build can potentially get an outdated version of the curl and nginx packages.

Using RUN apt-get update && apt-get install -y ensures your Dockerfile installs the latest package versions with no further coding or manual intervention. This technique is known as “cache busting”. You can also achieve cache-busting by specifying a package version. This is known as version pinning

Avoid RUN apt-get upgrade and dist-upgrade, as many of the “essential” packages from the parent images cannot upgrade inside an unprivileged container. If a package contained in the parent image is out-of-date, contact its maintainers. If you know there is a particular package, foo, that needs to be updated, use apt-get install -y foo to update automatically.

This should be the same as @gile's answer with those best practices applied

FROM ubuntu:15.10
RUN  apt-get -y update \
     && apt-get -y autoremove \
     && apt-get clean \
     && apt-get install -y p7zip \
     p7zip-full \
     unace \
     zip \
     unzip \
     xz-utils \
     sharutils \
     uudeview \
     mpack \
     arj \
     cabextract \
     file-roller \
     && rm -rf /var/lib/apt/lists/*

CMD ["bash"]

*edit

The Docker best practices documentation has been re-arranged.

The advice remains the same. While the part of documentation that the above link anchors to now merely alludes to concerns between build cache and apt-get...

They have added a new section of documentation dedicated to this topic.

https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#apt-get

in short:

Always combine RUN apt-get update with apt-get install in the same RUN statement

Tags:

Docker