Search code examples
dockerdocker-composedockerfileopenwrt

How is openwrtorg/rootfs:19.07.4 actually building?


I have been trying to do some customization to the openwrtorg/rootfs:19.07.4 (here) container

The written Dockerfile is

MAINTAINER Paul Spooren <mail@aparcar.org>
ADD dir:2bf606039dd1f357b8d8655abcc8470848e0165b167803c02a816ae3d5d69f9b in /
EXPOSE 22 443 80
USER root
CMD ["/sbin/init"]

I don't understand how the container is being created without FROM command and second how is data being added to the container

ADD dir:2bf606039dd1f357b8d8655abcc8470848e0165b167803c02a816ae3d5d69f9b in /

what exactly is this command doing.

Here is the link to their GitHub repository.


Solution

  • The "Dockerfile" listing on Docker Hub isn't an actual copy of the image's original Dockerfile; instead, it shows what it's possible to extract from the docker history of the image. That means that the base image(s) will be flattened into a single listing, so the whole thing implicitly starts FROM scratch, and anything that gets COPY or ADDed to the image shows that hash format rather than the original file path.

    The GitHub repository you link to has a Dockerfile.rootfs which should look more familiar. I'll copy it here, with some annotations:

    # Don't use any base image at all; start from an empty filesystem.
    # This is the starting point for anything that unpacks a Linux
    # distribution images.  All images eventually come back to this if
    # you follow their FROM, and their base image's FROM, and ...
    # Not shown in the Docker Hub output.
    FROM scratch
    
    MAINTAINER Paul Spooren <mail@aparcar.org>
    
    # Copy the root filesystem into the (completely empty) image.
    # The Docker Hub output just shows a hash of what got copied in.
    ADD ./ /
    
    # These are identical to the Docker Hub output.
    EXPOSE 80 443 22
    USER root
    CMD ["/sbin/init"]
    

    Since this is a base image – it's constructed in a similar way to the debian, ubuntu, or alpine images – you can build your own image by starting it FROM openwrtorg/rootfs:19.07.4 and proceeding from there.