Tutorial: Publish Your First Docker Image to EBRAINS Registry

In this tutorial, you’ll containerize a simple web application and publish it to the EBRAINS Docker Registry, making it available for deployment across EBRAINS infrastructure.

What you’ll build: A containerized Python Flask app published to EBRAINS Harbor registry.

Time required: 25-35 minutes

Prerequisites:

Part 1: Verify Docker Installation

Step 1: Check Docker is Installed

Expected output:

If you see “command not found”, install Docker first:

Step 2: Verify Docker is Running

If you see a table header (even if empty), Docker is running:

Part 2: Create a Simple Web Application

Let’s create a simple Python Flask app to containerize.

Step 3: Create Project Directory

Step 4: Set Up Virtual Environment

Create and activate a Python virtual environment:

Your terminal prompt should now show (venv) indicating the virtual environment is active.

Step 5: Create the Application

Create app.py with the following command:

Step 6: Create Requirements File

Create requirements.txt with the following command:

Step 7: Test Locally (Optional)

Before containerizing, test the app works:

Open another terminal and test:

You should see:

Press Ctrl+C to stop the app.

Part 3: Containerize Your Application

Step 8: Create a Dockerfile

Create Dockerfile (no extension) with the following command:

Step 9: Create .dockerignore

Create .dockerignore to exclude files from the image:

Step 10: Build Your Docker Image

What this does:

  • docker build - Build an image
  • -t my-ebrains-app:1.0.0 - Tag it as “my-ebrains-app” version “1.0.0”
  • . - Use current directory as build context

Expected output:

Step 11: Verify Your Image

You should see your image:

Step 12: Test Your Container Locally

In another terminal, test it:

If it works, press Ctrl+C to stop the container.

Part 4: Access EBRAINS Docker Registry

Step 13: Get Your CLI Secret

The EBRAINS Docker Registry uses Harbor. You’ll need your CLI secret (not your regular password).

  1. Visit EBRAINS Docker Registry
  2. Log in with your EBRAINS credentials
  3. Click your username in the top-right corner
  4. Select “User Profile”
  5. Find the “CLI secret” section
  6. Click “Generate CLI secret” or copy the existing one

CLI Secret Location

Step 14: Login to EBRAINS Registry

Enter when prompted:

  • Username: Your EBRAINS username (usually email)
  • Password: Your CLI secret (NOT your EBRAINS password)

Expected output:

Part 5: Create a Harbor Project

Step 15: Create Your Project

Harbor organizes images into projects (like namespaces).

  1. Go to EBRAINS Registry Projects
  2. Click “New Project” (top left)
  3. Fill in the form:
    • Project Name: my-project (lowercase, hyphens allowed)
    • Access Level:
      • Private (default) - Only members can pull
      • Public - Anyone authenticated can pull
  4. Click “OK”

Part 6: Push Your Image to EBRAINS Registry

Step 16: Tag Your Image for EBRAINS Registry

Docker images must be tagged with the full registry path:

Format breakdown:

Verify the new tag:

You should see both tags pointing to the same image ID:

Step 17: Push to the Registry

Expected output:

Step 18: Verify in Harbor UI

  1. Go to EBRAINS Registry
  2. Click “Projects” in the left sidebar
  3. Click on “my-project”
  4. You should see “my-ebrains-app” listed
  5. Click on the image name to see:
    • All tags (versions)
    • Image size
    • Vulnerability scan results
    • Pull command
    • Creation date

Part 7: Pull and Run Your Image

Step 19: Clean Local Images (Optional)

To simulate pulling from another machine, remove your local images:

Step 20: Pull from EBRAINS Registry

Expected output:

Step 21: Run the Pulled Image

Flags explained:

  • -d - Run in detached mode (background)
  • -p 5000:5000 - Map port 5000 (host:container)
  • --name my-app - Name the container “my-app”

Test it’s running:

View running containers:

Stop the container when done:

Part 8: Version Management

Step 22: Create a New Version

Let’s update the app and publish version 2.0.0:

Edit app.py to change the version:

Step 23: Build, Tag, and Push New Version

Step 24: Verify Multiple Versions

In Harbor UI, you should now see:

  • 1.0.0 (145 MB, created 20 minutes ago)
  • 2.0.0 (146 MB, created 2 minutes ago)
  • latest (146 MB, created 2 minutes ago)

Part 9: GitLab CI/CD Integration

Step 25: Automate Builds with GitLab CI

Create .gitlab-ci.yml in your project:

Step 26: Set GitLab CI/CD Variables

In your GitLab project:

  1. Go to SettingsCI/CDVariables
  2. Add two variables:
    • CI_REGISTRY_USER: Your EBRAINS username
    • CI_REGISTRY_PASSWORD: Your CLI secret (mark as “Masked”)

Now every push to main or develop automatically builds and pushes!

Next Steps

Now that you’ve published your first image, you can:

  1. Automate with CI/CD - Set up GitLab pipelines to build on every commit
  2. Deploy to Kubernetes - Use your images in EBRAINS Kubernetes clusters
  3. Add health checks - Improve Dockerfile with HEALTHCHECK instruction
  4. Scan for vulnerabilities - Review Harbor’s security scan results
  5. Create image variants - Build images for different environments (dev/staging/prod)

Additional Resources

Summary

You’ve successfully:

  • Created a containerized web application
  • Built a Docker image with proper structure
  • Authenticated with EBRAINS Docker Registry
  • Created a Harbor project
  • Published multiple image versions
  • Pulled and ran images from the registry
  • Learned version management strategies
  • Set up GitLab CI/CD automation