Hi,
Want to check if there is a docker image/Dockerfile for zstd which is officially supported? I could not find one under dockerhub official images https://hub.docker.com/explore/
If not, want to check if there is any plan to add an official zstd image to dockerhub? https://docs.docker.com/docker-hub/official_repos/#how-do-i-create-a-new-official-repository
We haven't planned any docker image.
It seems like a reasonable idea, though the support of someone experienced in this process would be gladly welcomed.
To be clear, you're looking for a docker image that contains a pre-built zstd binary?
If so, here is a dockerfile that generates such an image (note: it uses a multi-stage build, and requires docker >= 17.05 to build the image):
# Dockerfile
# First image to build the binary
FROM alpine as builder
RUN apk --no-cache add make gcc libc-dev
COPY . /src
RUN mkdir /pkg && cd /src && make && make DESTDIR=/pkg install
# Second minimal image to only keep the built binary
FROM alpine
# Copy the built files
COPY --from=builder /pkg /
# Copy the license as well
RUN mkdir -p /usr/local/share/licenses/zstd
COPY --from=builder /src/LICENSE /usr/local/share/licences/zstd/
# Just run `zstd` if no other command is given
CMD ["/usr/local/bin/zstd"]
Then in the zstd directory:
$ docker build -t zstd .
$ echo foo | docker run -i --rm zstd | docker run -i --rm zstd zstdcat
foo
This results in a 6.42MB image.
Would it be useful to host such a script is /contrib/docker ?
I suppose. I think the main idea is to use this script to build an image, and then push this image to the official docker hub - ideally people would use this official image rather than create one themselves.
So it's more of an internal-use script, but it may still be a good idea to keep it in this repository, and contrib/docker sounds like a good place for that.
There may be some more bikeshedding regarding the default command/entrypoint:
CMD to ["zstd"] allows to run:docker run zstd for the default zstd command without parameters (simple)docker run zstd zstd -9 for the zstd command with parameters (the repetition might be a bit weird)docker run zstd zstdcat for other binaries (the repetition might be a bit weird here as well)ENTRYPOING to ["zstd"] allows:docker run zstd -9 to use the zstd command directly with parameters (looks good)docker run --entrypoint zstdcat zstd for other binaries (the zstdcat/zstd inversion may look weird)I'm not sure which of these two configurations is the most user-friendly one.
maybe calling it zstd_image or anything else
would avoid the confusion with the executable name ?
That's true; though the current standard is for images to have directly the name of the binary/service they provide: mysql, openjdk, ...
As a note, there's an unofficial lz4 image (though it doesn't appear to be very active, and has no documentation whatsoever). This one just sets a CMD to bash, so it needs to be called this way:
docker run sguthrie/lz4 lz4 -9
I've been trying to use the proposed Dockerfile by @gyscos to create a docker image.
As a warning, my docker skills are pretty limited, so I'm merely copy/pasting suggested script in a local file called Dockerfile. I'm using Ubuntu LTS 16.04 as baseline for this test.
Attempt 1 :
$ docker build -t zstd .
Got permission denied while trying to connect to the Docker daemon socket
Attempt 2 :
$ sudo docker build -t zstd .
Sending build context to Docker daemon 2.56 kB
Step 1/9 : FROM alpine as builder
Error parsing reference: "alpine as builder" is not a valid repository/tag: invalid reference format
Also :
requires docker >= 17.05
$ docker -v
Docker version 1.13.1, build 092cba3
Versions do not match, but I'm wondering if these numbers are related.
1.13.1 is the old versioning scheme and is therefore older than 17.05.
Upgrading will allow you to build it.
Most helpful comment
That's true; though the current standard is for images to have directly the name of the binary/service they provide: mysql, openjdk, ...
As a note, there's an unofficial lz4 image (though it doesn't appear to be very active, and has no documentation whatsoever). This one just sets a
CMDtobash, so it needs to be called this way: