Home:ALL Converter>GDAL Image Dependency via Docker or Docker Compose

GDAL Image Dependency via Docker or Docker Compose

Ask Time:2021-01-08T03:12:33         Author:Nathan Raley

Json Formatter

I am trying to figure out Docker and/or Docker Compose settings in order to add the GDAL libraries or container image dependency within my sample/test application so that I can execute GDAL commands via bin/bash within my console and eventually a web application boxed within their own Docker container.

Right now, I have a console application that I am attempting to run that I need to have a dependency on an existing Docker image: geodata/gdal:ubuntu-full-3.2.0.

I currently have my docker compose set up as the following:

version: '3.4'

services:
    gdal:
        image: "geodata/gdal:ubuntu-full-3.2.0"
    satellites.console:
        image: ${DOCKER_REGISTRY-}satellitesconsole
        build:
            context: .
            dockerfile: Satellites.Console/Dockerfile
        depends_on:
            - gdal

My dockerfile for the console application is just a bare bones to copy, build, and publish the console application:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["Satellites.Console/Satellites.Console.csproj", "Satellites.Console/"]
RUN dotnet restore "Satellites.Console/Satellites.Console.csproj"
COPY . .
WORKDIR "/src/Satellites.Console"
RUN dotnet build "Satellites.Console.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Satellites.Console.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Satellites.Console.dll"]

From my understanding, that GDAL container image should contain, and install, all the required pieces to use the GDAL library within it's container. I want to bring those dependencies and over with my console application so I can run bin/bash to run against the GDAL libraries. I was hoping to be able to achieve this via something along the lines of this:

ProcessStartInfo startInfo = new ProcessStartInfo() { FileName = "/bin/bash", Arguments = @"gdalinfo --version", RedirectStandardOutput = true, UseShellExecute = false };
Process proc = new Process() { StartInfo = startInfo, };
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
System.Console.WriteLine(result);

Am I going about this the correct way?

I've tried everything from the current settings to copying the Dockerfile from the source repo to try and install everything within my console container (I think I need the .sh files that are included there to get it to install this way, but I have no idea of what to do with those, since running the build for it doesn't appear to do any installations or anything). No matter what approach I've used, I am not getting any luck running the bash from the console application, I get the

/bin/bash: gdalinfo: No such file or directory

meaning either it's not installing the dependencies, or the PATHS aren't getting setup correctly.

Has anyone tried and succeeded in setting their Docker container environment up this way before? Being new to how Docker and the containers work, I'm sort of lost at this point.

Author:Nathan Raley,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/65618552/gdal-image-dependency-via-docker-or-docker-compose
yy