{"id":19398010,"url":"https://github.com/geocompx/docker","last_synced_at":"2025-04-24T05:31:23.481Z","repository":{"id":40000073,"uuid":"255254078","full_name":"geocompx/docker","owner":"geocompx","description":"Dockerfiles for Geocomputation","archived":false,"fork":false,"pushed_at":"2024-10-16T09:32:12.000Z","size":310,"stargazers_count":40,"open_issues_count":13,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-18T04:05:22.738Z","etag":null,"topics":["docker","docker-image"],"latest_commit_sha":null,"homepage":"https://github.com/geocompx/docker/pkgs/container/docker","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geocompx.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-13T06:56:42.000Z","updated_at":"2024-10-16T09:32:16.000Z","dependencies_parsed_at":"2023-12-30T10:22:16.165Z","dependency_job_id":"f603dec7-72fa-4746-a621-aeb477e513a8","html_url":"https://github.com/geocompx/docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geocompx%2Fdocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geocompx%2Fdocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geocompx%2Fdocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geocompx%2Fdocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geocompx","download_url":"https://codeload.github.com/geocompx/docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223942721,"owners_count":17229112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image"],"created_at":"2024-11-10T11:04:37.053Z","updated_at":"2025-04-24T05:31:23.472Z","avatar_url":"https://github.com/geocompx.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\"\n)\n```\n\n# Geocomputation with Docker\n\n[![](https://img.shields.io/docker/pulls/geocompr/geocompr?style=plastic)](https://github.com/geocompx/docker/blob/master/)\n\nThis repo documents Docker images for geographic research and reproducing code in the books *Geocomputation with R* and *Geocomputation with Python*.\nThe Dockerfiles build on work done for the [Rocker Project](https://www.rocker-project.org/).\nAs documented on the Rocker Project website, Docker can save time and increase reproducibility by providing an environment with up-to-date and stable software.\n\nTo get started, after you [install Docker](https://docs.docker.com/get-docker/), try running one of the following commands:\n\n```{r, engine='bash', eval=FALSE}\n# The latest version of rocker/geospatial + geocompr dependencies\ndocker run -e PASSWORD=pw --rm -p 8786:8787 ghcr.io/geocompx/docker\n# With up-to-date OSGeo packages and qgisprocess:\ndocker run -e PASSWORD=pw --rm -p 8786:8787 ghcr.io/geocompx/osgeo\n```\n\nIf you are asked for a username and password, then you should use `rstudio` as your username and the password you set with the above code (e.g., `pw`).\n\nThen open a browser at http://localhost:8786/, and you should see something like this:\n\n![](https://user-images.githubusercontent.com/1825120/79639334-33eb9f00-8183-11ea-8358-588fe17afe25.png)\n\nIf so congratulations 🎉 you can proceed to open the `geocompr.Rproj` project or other files in the `geocompr` folder, which contains a complete copy of the source code and example data needed to build the html version of the book.\n\nTo run a container without RStudio, try the following.\n\n```\ndocker run -e PASSWORD=pw --rm -ti ghcr.io/geocompx/docker /bin/bash\n```\n\nUse this resource to play with the examples, develop new answers to the questions at the end of each page, or even to generate reproducible examples to illustrate [issues](https://github.com/geocompx/geocompr/issues) with the books contents.\n\nIf not, see documentation on using Docker at websites such as [docker.com](https://docs.docker.com/get-started/) and https://www.rocker-project.org/.\n\n## Sharing folders with Docker\n\nTo use these Docker images for your own work you will need to share files with Docker.\nThat means sharing 'volumes'.\nYou can do this using the `-v` argument as shown below, which shares your current working directory with the Docker container.\nIf you run these commands in a terminal that has access to Docker, like `bash` or Windows `PowerShell` you should get a local copy of *Geocomputation with R* on your computer that you can use for testing and development purposes, e.g. to test changes before submitting a Pull Request to improve the book:\n\n```bash\n# download repo with Windows Powershell or a Unix terminal\ngit clone https://github.com/geocompx/geocompr.git \n# or download manually from https://github.com/geocompx/geocompr/archive/main.zip\ncd geocompr # navigate into the repo\n# on linux and mac with password:\ndocker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data -e USERID=$UID -e PASSWORD=pw ghcr.io/geocompx/minimal\n# on linux and mac without password:\ndocker run -d -p 8786:8787 -e DISABLE_AUTH=TRUE -v $(pwd):/home/rstudio/geocompr  ghcr.io/geocompx/minimal\n```\n\n![](https://user-images.githubusercontent.com/1825120/39538109-9b50e7ac-4e33-11e8-93b3-e00e95a79294.png)\n\nIf you see something like this after following the steps above, congratulations: it worked!\nSee [github.com/rocker-org](https://github.com/rocker-org/rocker/wiki/Using-the-RStudio-image#running-rstudio-server) for more info.\n\nYou can also pull and run the same images from ghcr.io, e.g. as follow:\n\n```bash\n# For latest version:\ndocker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data -e PASSWORD=pw ghcr.io/ghcr.io/geocompx/minimal\n# For a specific version/date (see https://github.com/geocompx/docker/pkgs/container/minimal):\ndocker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data -e PASSWORD=pw ghcr.io/ghcr.io/geocompx/minimal:date_2024-10-14\n```\n\nFrom this point to *build* the book you can open projects in the `geocompr` directory from the project box in the top-right hand corner, and  knit `index.Rmd` with the little `knit` button above the the RStudio script panel (`Ctl+Shift+B` should do the same job).\n\nThere are various versions of the `geocompr` Docker image available.\nThe default is the `latest` tag, representing the `Dockerfile` in the root of this repo, but you can get other images, as outlined below.\n\n## Versions\n\nBuilding on the [rocker-org](https://github.com/rocker-org/rocker-versioned/blob/master/README.md)  project, we provide various versions for testing and development, including builds that use more up-to-date versions of OSGeo packages such as GDAL provided by the [UbuntuGIS software repository](https://wiki.ubuntu.com/UbuntuGIS), as shown below:\n\nimage            | description                               | size   \n---------------- | ----------------------------------------- | ------ \n[latest](https://github.com/geocompx/docker/pkgs/container/docker/)            |  docker pull ghcr.io/ghcr.io/geocompx/latest   image + book files  | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=latest)\n[minimal](https://github.com/geocompx/docker/blob/master/minimal)   |  docker pull ghcr.io/ghcr.io/geocompx/minimal rocker/geospatial plus geocompkg Imports | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=minimal)\n[suggests](https://github.com/geocompx/docker/blob/master/suggests) |  docker pull ghcr.io/ghcr.io/geocompx/suggests includes all packages from geocompkgs (Suggests) | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=suggests)\n[binder](https://github.com/geocompx/docker/blob/master/binder)     |  docker pull ghcr.io/ghcr.io/geocompx/binder runs with Binder | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=binder)\n[osgeo](https://github.com/geocompx/docker/blob/master/)             |  docker pull ghcr.io/ghcr.io/geocompx/osgeo running on rocker/geospatial:osgeo  | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=osgeo)\n[buildbook](https://github.com/geocompx/docker/blob/master/)         |  docker pull ghcr.io/ghcr.io/geocompx/buildbook runs the book code  | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=buildbook)\n[qgis](https://github.com/geocompx/docker/blob/master/)              |  docker pull ghcr.io/ghcr.io/geocompx/qgis with QGIS  | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=qgis)\n[rocker-rpy](https://github.com/geocompx/docker/blob/master/)              |  docker pull ghcr.io/ghcr.io/geocompx/rocker-rpy with python  | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=rocker-rpy)\n[rocker-rpyjl](https://github.com/geocompx/docker/blob/master/) | docker pull ghcr.io/ghcr.io/geocompx/rocker-rpyjl with R, Python, and Julia | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=rocker-rpyjl)\n[python](https://github.com/geocompx/docker/blob/master/)            |  docker pull ghcr.io/ghcr.io/geocompx/python Python image + geo pkgs  | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=python)\n[rust](https://github.com/geocompx/docker/blob/master/)            |  docker pull ghcr.io/ghcr.io/geocompx/rust with Rust  | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=rust)\n[pixi-r](https://github.com/geocompx/docker/blob/master/)            |  docker pull ghcr.io/ghcr.io/geocompx/pixi-r | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=pixi-r)\n[pixi-py](https://github.com/geocompx/docker/blob/master/)            |  docker pull ghcr.io/ghcr.io/geocompx/pixi-py | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=pixi-py)\n[pixi-rpy](https://github.com/geocompx/docker/blob/master/)            |  docker pull ghcr.io/ghcr.io/geocompx/pixi-rpy | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=pixi-rpy)\n[mamba-py](https://github.com/geocompx/docker/blob/master/)            |  docker pull ghcr.io/ghcr.io/geocompx/mamba-py | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=mamba-py)\n[mamba-pyr](https://github.com/geocompx/docker/blob/master/)            |  docker pull ghcr.io/ghcr.io/geocompx/mamba-pyr | ![](https://ghcr-badge.deta.dev/geocompx/docker/size?tag=mamba-pyr)\n\nThe base image is `rocker/geospatial` from [github.com/rocker-org/rocker-versioned2](https://github.com/rocker-org/rocker-versioned2).\n\nAdd :tagname after ghcr.io/geocompx/docker to get the image you want.\n\n\u003c!-- To run the `buildbook` version (represented by the extension `-b` for most tags), for example, run the following command (with port and password set to a port of your preference): --\u003e\n\n```{r, engine='bash', eval=FALSE}\ndocker run -e PASSWORD=pw --rm -p 8786:8787 ghcr.io/geocompx/buildbook\n```\n\n### Note on pixi based images in devcontainers\n\nFor [reasons we don't understand on the pixi side](https://github.com/prefix-dev/pixi/discussions/2088), you must set the locale with something like\n\n```\n  \"postCreateCommand\": \"apt update \u0026\u0026 apt install -y --no-install-recommends locales; echo \\\"en_US.UTF-8 UTF-8\\\" \u003e\u003e /etc/locale.gen; locale-gen\",\n```\n\nIf you use these in a [devcontainer](https://github.com/geocompx/geocompr/blob/77dd6207c3b0e1a51d62202c62d5d045c2961038/.devcontainer.json#L1-L9).\n\n## Examples\n\n### osgeo\n\nTo test your code or package against recent versions of OSGeo libraries (GDAL, GEOS, PROJ), you can run the following command from inside root directory of the folder containing the code:\n\n```bash\n# on linux and mac with password:\ndocker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data \\\n  -e USERID=$UID -e PASSWORD=pw ghcr.io/geocompx/osgeo\n```\n\n### Python\n\nThe Python tag contains Python geospatial packages:\n\n```bash\ndocker run -e PASSWORD=pw --rm -ti ghcr.io/geocompx/python /bin/bash\n\npython3\nimport pandas as pd\nimport geopandas as gpd\nimport movingpandas as mpd\n```\n\nYou can run an interactive session via Reticulate in RStudio as follows:\n\n```bash\ndocker run -e PASSWORD=pw --rm -p 8786:8787 ghcr.io/geocompx/python\n```\n\nAnd then in the resulting RStudio session you can enter something along the lines of:\n\n```r\nlibrary(sf)\nf = file.path(system.file(\"shape/nc.shp\", package=\"sf\"))\nnc_sf = read_sf(f)\nlibrary(reticulate)\nsystem(\"pip3 install descartes\")\ngp = import(\"geopandas\")\nnc_gp = gp$read_file(f)\nclass(nc_gp)\nplot(nc_gp$AREA, nc_gp$PERIMETER)\ngp = import(\"geopandas\", convert = FALSE)\nnc_gp = gp$read_file(f)\nnc_gp\nplt = import(\"matplotlib.pyplot\", convert = FALSE)\nnc_gp$plot()\nplt$savefig(\"test.png\")\n```\n\nTo plot from Python packages (work in [progress](https://github.com/geocompr/docker/issues/12)).\n\n\n### QGIS\n\nTo run QGIS from the command line, you can run:\n\n```bash\ndocker pull ghcr.io/geocompx/qgis\ndocker run --rm -ti ghcr.io/geocompx/qgis /bin/bash\nqgis --version\n# QGIS 3.20.3-Odense 'Odense' (495fbaecaf)\n```\n\nYou can also run QGIS algorithms via the `qgisprocess` package as follows:\n\n```\ndocker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data -e PASSWORD=pw ghcr.io/geocompx/qgis\n```\n\nThen open a browser and the local url such as http://192.168.0.99:8786/ or http://localhost:8786, enter RStudio server, and you should be able to access QGIS as follows in the R console:\n\n```{r, eval=FALSE}\nsystem(\"qgis --version\")\n## QGIS 3.16.1-Hannover 'Hannover' (b381a90dca)\nremotes::install_github(\"paleolimbot/qgisprocess\") # install the latest version of the package\nqgis_algs = qgisprocess::qgis_algorithms()\nnrow(qgis_algs)\n## [1] 303\ntable(qgis_algs$provider)\n##    3d   gdal native   qgis \n##     1     55    196     51 \n```\n\n### QGIS extensions\n\nYou can access algorithms from other GIS programs through QGIS but they need to be installed.\nThese can be accessed from the `ghcr.io/geocompx/qgis` image as follows:\n\n```\ndocker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data -e PASSWORD=pw ghcr.io/geocompx/qgis\n```\n\nAgain, open the browser, e.g. at http://localhost:8786, and find the new algorithms as follows:\n\n\n```{r, eval=FALSE}\nsystem(\"qgis --version\")\n## QGIS 3.16.1-Hannover 'Hannover' (b381a90dca)\nremotes::install_github(\"paleolimbot/qgisprocess\") # install the latest version of the package\n## Skipping install of 'qgisprocess' from a github remote, the SHA1 (6e378511) has not changed since last install.\nqgis_algs = qgisprocess::qgis_algorithms()\nnrow(qgis_algs)\n## [1] 970\ntable(qgis_algs$provider)\n\n##    3d   gdal grass7 native   qgis   saga \n##     1     55    301    196     51    366 \n```\n\nCongratulations, you now have nearly 1000 QGIS algorithms at your disposal from the R command line 🎉\n\n## Building the images locally\n\nYou can build the images locally, e.g. as follows:\n\n```bash\ndocker build qgis -t test\ndocker run -p 8888:8888 test\ndocker build conda -t geocompy\ndocker run -it geocompy /bin/bash\ndocker build  -t \n```\n\nYou should then be able to run commands in the newly created images, e.g. with:\n\n```bash\ndocker run -it  /bin/bash\n```\n\n### Using GitHub PAT with BuildKit secret mounts\n\nSome images (like `suggests` and `rust`) require GitHub API access to install packages from GitHub repositories. To avoid hitting GitHub API rate limits, you can securely pass a GitHub Personal Access Token (PAT) during the build process using BuildKit secret mounts:\n\n1. First, create a GitHub Personal Access Token by following the instructions at [GitHub Docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)\n\n2. Save your token to a file (but don't commit this file to version control):\n   ```bash\n   echo \"your_github_token\" \u003e GITHUB_PAT.txt\n   ```\n\n3. Build the image using BuildKit secret mounts:\n   ```bash\n   # Enable BuildKit\n   export DOCKER_BUILDKIT=1\n   \n   # Build with secret mount\n   docker build --secret id=GITHUB_PAT,src=GITHUB_PAT.txt -t geocompx/suggests suggests\n   ```\n\nThis approach is more secure than using build arguments or environment variables because the secret is only available during the specific build steps that need it and is not stored in any image layer or build cache.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeocompx%2Fdocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeocompx%2Fdocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeocompx%2Fdocker/lists"}