Skip to content

Interactive session in a docker container

F.Moser edited this page Oct 20, 2022 · 2 revisions

It's possible to have an interactive accessmod session from a docker container

Launch a container

docker run -ti --rm fredmoser/accessmod:latest  R

Run commands in an accessmod-grass session from R

# Load dependencies an configuration
source('global.R')
# Start namespace session on the project demo. expr is required – for now. ls() is enough. 
amGrassNS(mapset='demo',location='demo',expr=quote(ls()))
# Execute any GRASS commands. E.g. v.what.rast
execGRASS("g.list",type="raster")
execGRASS("g.list",type="vector")
dfResult <- execGRASS("v.what.rast",raster="rLandCover__demo",map="vFacility__demo",flags="p",intern=T) %>% amCleanTableFromGrass()
names(dfResult) <- c("cat","value")
head(dfResult)

From a compose running container

docker compose exec am_main R
> source('global')
...