ShockwaveNN
ShockwaveNN

Reputation: 2268

Docker - require specific docker service version

Currently I have a bug, maybe in my code, maybe in docker base images, maybe even in docker itself, but I know for sure, that my app works great on docker-ce 17.09 and hang up after some time on docker-ce 17.12
Is there any way to specify docker version in Dockerfile or in docker-compose.yml so app will throw error while trying to build it on not supported docker version.
I understand this is not a good idea, and I need to find out this bug, but for temporary workaround this error message is enough for me.

Upvotes: 2

Views: 176

Answers (1)

Mazel Tov
Mazel Tov

Reputation: 2182

i think there is no docker direct approach to it. But you can pass the docker version with ARG to your Dockerfile and then add RUN command that checks if it is the required version. To cancel the build process you have to exit with other number than 0.

build your image with this line

docker_version=`docker version --format "{{.Server.Version}}"` \
&& docker build -t my_image --build-arg DOCKER_VERSION=$docker_version . 

then in your Dockerfile check if it is required docker version

FROM debian

ARG DOCKER_VERSION

RUN [[ $DOCKER_VERSION == "17.12.0-ce" ]] && echo "YES" ||  exit 1

Upvotes: 2

Related Questions