I have a python script that I'd want to run on 2 different containers running python 2.7 and python 3.6.
I want to use the same docker file to build 2 different images, with the difference being the python version(i.e one time it's FROM python:3.6 and the other is FROM python:2.7, and do it through a makefile.
Makefile
.PHONY = all clean build run
all: build run
# DOCKER TASKS
# Build the container
build: ## Build the container for tests
docker build -t myscript:python2.7 .
docker build -t myscript:python3.6 .
run: ## Run container
docker run myscript:python2.7
docker run myscript:python3.6
I have a Dockerfile for building the image: Dockerfile
FROM python:3.6
WORKDIR /usr/local/bin
RUN pip install pytest
COPY myscript.py test_regex_script.py ./
CMD ["pytest", "test_regex_script.py"]
Since it's the same Docker file it's tricky, I was thinking to create two different Dockerfiles each with a different python version (and all the rest the same), but was wondering if there's more elegant way to do it.
thanks