Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Using Docker

Introduction

Why Use Docker for Geospatial Programming?

Learning Objectives

Installing Docker Desktop

Windows and macOS

Linux

Verifying Installation

docker --version

Basic Concepts

Images vs. Containers

Key Docker Terms

Running Code Examples in Docker

docker pull giswqs/pygis:book
docker run -it -p 8888:8888 -v $(pwd):/app/workspace giswqs/pygis:book

Working with Files

Stopping a Container

Listing Running Containers

docker ps

Common Docker Commands

Basic Operations

# Pull an image from Docker Hub
docker pull giswqs/pygis:book

# List downloaded images
docker images

# List running containers
docker ps

# List all containers (including stopped ones)
docker ps -a

# Stop a container
docker stop container_name

# Remove a container
docker rm container_name

# Remove an image
docker rmi image_name

Getting Help

# Get help for any Docker command
docker help
docker run --help

Choosing Port Numbers

# Use port 8889 instead
docker run -it -p 8889:8888 -v $(pwd):/app/workspace giswqs/pygis:book

Saving Your Work

Key Takeaways

Exercises

Exercise 1: First Docker Run

docker run -it -p 8888:8888 -v $(pwd):/home/jovyan/work ghcr.io/opengeos/leafmap:latest

Exercise 2: Exploring the Environment

import geopandas as gpd
import rasterio
import leafmap
print("All libraries imported successfully!")
import leafmap.maplibregl as leafmap
m = leafmap.Map(projection="globe")
m

Exercise 3: Working with Different Ports

Exercise 4: Docker Commands Practice