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 Show archive.org snapshot .
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:
#!/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:
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
:
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
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:
docker ps
docker stats
docker stop imagemagick-docker