Setting up a new CKAN development environment using Docker is a convenient way to quickly get started with CKAN development without worrying about the intricacies of dependency management and environment setup. Docker containers provide a consistent and easily managed environment across different machines.

In this exercise, we will create a new CKAN extension called “ckanext-pigeon”

We first need to download the ckan-docker repository:

git clone https://github.com/ckan/ckan-docker 

This will create a directory called ckan-docker. We will rename that directory to ckan-docker-pigeon

We then need to create the Docker Compose environment file called .env For convenience we copy the example .env file as follows:

cd ckan-docker-pigeon/

cp .env.example .env

Within the .env file we set the CKAN_SITE_URL parameter to be http://localhost:5000

The CKAN Development environment uses a development version of the Docker Compose file (docker-compose.dev.yml)and the Dockerfile (Dockerfile.dev)

Next we build the local images and then run containers off these images as follows:

docker compose -f docker-compose.dev.yml build 

docker compose -f docker-compose.yml up (ie: run containers)

We then bring up a VS Code Development IDE by running the following command 

code .

We have a screen that looks like the following:

From the host machine we then need to generate a CKAN extension template into a specific directory located within the running CKAN container using the following script

docker compose -f docker-compose.dev.yml exec ckan-dev ckan generate extension -o /srv/app/src_extensions

Now we can get a shell on the running CKAN dev container and change directory into the src_extensions. We see the ckanext-pigeon extension has been created

cd /srv/app/src_extensions; ls

In the Docker Compose file we have a Docker volume configured that allows us to map a local directory to a (remote) directory within the running CKAN container 

ie:  src/ (local) → /srv/app/src_extension/ (remote)

This type of volume mapping in Docker is called a bind mount and is a way to link a directory or file on the host machine to a directory within a Docker container. It allows you to share files and directories between the host and the container, making it useful for development, debugging, and sharing data between the two environments.

We now have a way to run up a local Development environment  where changes are reflected immediately in the running CKAN Docker container.

Next, we need to update the .env file to add the pigeon extension to the end of the environment variable: CKAN___PLUGINS

We stop the stop and start all containers

docker compose -f docker-compose.dev.yml stop 

docker compose -f docker-compose.yml start

The new Pigeon CKAN extension (ckanext-pigeon) is now activated. It’s not “doing” anything but it is running as an extension within the CKAN container.

We can run http://localhost:5000/api/action/status_show to show the status of the CKAN application running within the CKAN container. It displays what plugins are installed.

And that’s it!


Related video: CKAN Extensions | Install into a new CKAN docker development environment

This video provides a step-by-step walkthrough for installing a CKAN docker development environment and seamlessly generating a new CKAN extension. Here’s a re

If you would like to learn more about CKAN and how you can establish developer operations to support your data portal projects please get in touch