Posted 16 days ago. Visible to the public.

Running old ImageMagick versions in a Docker container

If your project depends on an old version of ImageMagick that you can no longer install in your system, you can choose the run an old ImageMagick in a Docker container.

Dockerized ImageMagick commands will only work with absolute path arguments. You need to boot a corresponding docker container once before using it.

Setting up Docker

If you haven't installed Docker yet, use our guide or the official instructions.

Docker should work without sudo. Make sure that you follow the instructions to add your user to the docker group.

Building the image

Copy the attached Dockerfile in a local directory.

Run docker build . --tag bionic-imagemagick6:1.0 in said repository.

Forwarding ImageMagick commands to Docker

Now we have to replace the existing commands (located in /usr/bin/) with those of our Docker container.

Note that we cannot use Bash aliases are as we want to overwrite them in non-interactive shells as well.

Unpack the attached binaries to your ~/bin. Make sure each file is executable (chmod +x filename). For example, the convert command now looks like this:

Copy
#!/bin/bash docker exec imagemagick-docker "/usr/bin/convert" "$@"

Boot the container (see below), then open a new shell and ensure that convert -version outputs:

Copy
Version: ImageMagick 6.9.7-4 Q16 Features: Cipher DPC Modules OpenMP

If you still get the version from your system's ImageMagick, make sure that ~/bin is in your PATH. To do so, add the following to your ~/.profile:

Copy
if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi

Then open a new terminal. Once you boot the container, ImageMagick commands like convert should work as expected.

Booting the ImageMagick container

Copy
docker run --name imagemagick-docker -d --rm -u $(id -u ${USER}):$(id -g ${USER}) -v /home/${USER}:/home/${USER} -v /tmp:/tmp bionic-imagemagick6:1.0 /sbin/init

Furthermore, these commands might be helpful:

Copy
docker ps docker stats docker stop imagemagick-docker

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Michael Leimstädtner
Last edit:
8 days ago
by Michael Leimstädtner
Attachments:
binaries.zip, Dockerfile
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Michael Leimstädtner to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more