Most appropriate container for a data only container?

前端 未结 4 533
攒了一身酷
攒了一身酷 2021-02-05 02:33

What is the most appropriate (smallest, simplest) container to use for a data only Docker container?

In the documentation they use the training/postgres container. Howe

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 03:32

    This post recommends using an empty "scratch" container - no OS at all:

    Dockerfile:

    FROM scratch
    
    VOLUME /data
    ENTRYPOINT ["/no/such/file"]
    

    I just made an empty one, and the image is... 0 bytes!

    Then I COPY'd just a 2k file in during build, and the image is 260 bytes, so must be compressed.

    I am using this because named volumes aren't so useful in semi/serverless environments like AWS Fargate where is no host, and you want to deploy versioned data.

    Update: if you want the container to work correctly in docker-compose the above example won't work because the entrypoint fails. tianon/true seems to be the best solution, a tiny program which returns true. So you can use FROM tianon/true.

提交回复
热议问题