ImageMagick installation in Docker Alpine

6,462

Here's a similar Q/A that helped me on stackoverflow:
imagemagick installation in docker alpine

The file utility is not part of ImageMagick, it is a standard utility. You can read more about it on wikipedia:
File (command).

On Alpine Linux, you can install it with apk add --no-cache file. As shown in the following terminal session:

/ # file /etc/group
/bin/sh: file: not found
/ # apk add --no-cache file
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64
/APKINDEX.tar.gz
(1/2) Installing libmagic (5.32-r0)
(2/2) Installing file (5.32-r0)
Executing busybox-1.26.2-r5.trigger
OK: 9 MiB in 13 packages
/ # file /etc/group
/etc/group: ASCII text
/ #
Share:
6,462

Related videos on Youtube

Fdo
Author by

Fdo

Updated on September 18, 2022

Comments

  • Fdo
    Fdo over 1 year

    So I have this Dockerfile that attempts to install ImageMagick the following way:

    FROM ruby:2.4-alpine
    
    ...
    
    RUN apk --update add imagemagick
    
    ...
    

    The point is that the container doesn't recognizes the file utility (for content-type detection).

    Local environment (Mac OSX, installed imagemagick with brew):

    > file --version
    file-5.25
    magic file from /usr/share/file/magic
    
    > convert --version
    Version: ImageMagick 6.9.9-5 Q16 x86_64 2017-08-03 
    http://www.imagemagick.org
    Copyright: © 1999-2017 ImageMagick Studio LLC
    License: http://www.imagemagick.org/script/license.php
    Features: Cipher DPC Modules
    Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
    

    Docker Alpine container (accessed to the shell using docker exec -it CONTAINER_ID):

    > file --version
    sh: file: not found
    
    > convert --version
    Version: ImageMagick 6.9.5-9 Q16 x86_64 2016-10-21         
    http://www.imagemagick.org
    Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
    License: http://www.imagemagick.org/script/license.php
    Features: Cipher Modules
    Delegates (built-in): fontconfig freetype gslib jng jpeg lcms ltdl png ps tiff webp zlib
    

    Also tried installing imagemagick-dev by itself, and both of them combined without any luck (shouldn't make a difference since the first one is a dependency of the latter, I guess).

    The question is, how can I install this in the Alpine container? I think I'm missing something but can't figure it out.

    By the way, I can't rely on another function other than file for content-type detection since I'm using a framework that explicitly uses this.

  • Moj
    Moj over 6 years
    @mic84 Thanks for the point, it's really helpful to include the essential parts.