0

I have a console .Net Core application which also uses Python, nVidia CUDA runtime, etc.

I know about building patterns, but so far I just directly use build output of Visual Studio to create image, so my Dockerfile is simple:

FROM mcr.microsoft.com/dotnet/core/runtime:3.1.4-buster-slim AS base
FROM base AS final
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "MyApp.dll"]

In the same way as with the NetCore runtime, there're Python and nVidia CUDA images available. But if I just run another container with Python - my app is unable to use Python from this container, because containers are isolated and they may only interact using TCP. My thought was that I might use multiple images as base image for image with my app, but I don't see a way to use multiple FROM statements to combine one single image from them.

What's the proper way of using Python, CUDA and other images with environments from container with my running app, which only has NetCore runtime by default?

1 Answer 1

1

In the case where there's no container image that includes everything you want, you can write your own container image to build such a thing.

FROM mcr.microsoft.com/dotnet/core/runtime:3.1.4-buster-slim AS base

This container is based on Debian buster. That's a Linux distribution that has Python. It probably doesn't have CUDA, since Debian's all about Freedom and CUDA is non-free, to the best of my knowledge.

In this case, you can do 2 things:

  1. Install languages/libraries you need that are available in the distribution using the package manager

  2. Manually install things that are not available via the package manger.

So you probably want something like this:

FROM mcr.microsoft.com/dotnet/core/runtime:3.1.4-buster-slim AS base
RUN apt-get install -y python3
RUN wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/cluster_management/cuda_cluster_pkgs_10.2.89_440.33.01_ubuntu1804.tar.gz
RUN true # extract/install the tar file from above, I dont use CUDA so I dont know
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "MyApp.dll"]

This dockerfile starts with a container image that include .NET Core. Then it installs python in it. Then it installs CUDA in it. Then it runs your application.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That's what I also came to. I decided to cheat a bit and copied content of other docker files of images with stuff I need. Since CUDA has the biggest amount of dependencies I used CUDA as a base image and installed python + netcore runtime manually. I'm new to docker and this seems a bit counter intuitive that you can't just get a bunch of images and combine one that you need, instead you have to decide what's the most complex part and install other dependencies manually, even though there're tons of existing images for it. I understand why it's impossible to merge images though.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.