Wednesday, 10 May, 2017 UTC


Summary

It’s tempting to use the “:latest” tag of an image when you first get started with Docker and pulling images from DockerHub. After all, who wouldn’t want the latest and greatest version of MongoDB, Node.js, Redis, etc, when they start a project?
But this is a guaranteed way to ruin your life, destroy your productivity and rip your fancy new hair style to shreds, as you sit at your desk, pulling your hair out while stressing over why your project doesn’t run in your Docker container, a few weeks later.
Ok, it may not ruin your life, but it can certainly cause you to waste hours of it trying to figure out problems.
For example, a while back I was talking with a WatchMeCode member. After watching my Docker episode on running MongoDB in a Docker container, he made the jump.
He followed the instructions I provided in that screencast, set up the appropriate host mounted volume, and ran the container with all the right settings.
And none of his existing data showed up in the container.
After what felt like hours of running around in circles, he reached out and asked me if I had ever seen any issues like this. It took us a long time to figure out what the problem was…
His locally installed version of MongoDB was fairly old. It used an older file system driver, and created files that were not immediately supported by the newer version of MongoDB he was using in his Docker container.
It turned out he was using the latest MongoDB from Dockerhub, without thinking about upgrade issues like this.
In the end the solution was simple – specify the same, old version of MongoDB that he had installed directly on his laptop previously. Once he did this, the Docker container picked up the data file and everything worked fine.
This is only one example of upgrade blues, though.
I’ve had other experiences with upgrading Node.js versions and modules and libraries being incompatible with the newer version of Node.
If I were to specify the latest version of the Node image from Dockerhub, then I would be opening myself to the risk of running into this problem again.
At some point, the code I’m writing today will have an issue with a newer version of Node. It may not happen tomorrow, but it will happen.
It’s just too risky to use the :latest tag for a Docker image, unless you are in control of that image.
So save yourself the headache, and specify the right version of the right image for your Docker projects.
Tweet
The post Never Use The :latest Image From Docker Hub appeared first on DerickBailey.com.