如何在一个项目中管理多个DockerFile(最佳实践)

如何在一个项目中管理多个DockerFile(最佳实践),docker,Docker,我的项目有Dockerfile,但我想管理许多Dockerfile,这取决于Cuda版本 Dockerfile1: # Get the base Ubuntu image from Docker Hub and update packages. FROM nvidia/cuda:10.2-cudnn8-devel-ubuntu18.04 # Install prerequisites ARG DEBIAN_FRONTEND=noninteractive Dockerfile2: # Get t

我的项目有Dockerfile,但我想管理许多Dockerfile,这取决于Cuda版本

Dockerfile1:
# Get the base Ubuntu image from Docker Hub and update packages.
FROM nvidia/cuda:10.2-cudnn8-devel-ubuntu18.04
# Install prerequisites
ARG DEBIAN_FRONTEND=noninteractive

Dockerfile2:
# Get the base Ubuntu image from Docker Hub and update packages.
FROM nvidia/cuda:11.1-cudnn8-devel-ubuntu18.04
# Install prerequisites
ARG DEBIAN_FRONTEND=noninteractive

我该怎么做呢?

您可以在之前设置一个变量。它将是这样的:

ARG CUDA_VERSION='10.2'
# Get the base Ubuntu image from Docker Hub and update packages.
FROM nvidia/cuda:$CUDA_VERSION-cudnn8-devel-ubuntu18.04
# Install prerequisites
ARG DEBIAN_FRONTEND=noninteractive

星期二的问题不清楚,对不起。