Docker Server: Part 3

Deploying an EventStoreDB Database in Docker

In this post, I'll be deploying the EventStoreDB database in a Docker container. I'll start by configuring Portainer to make working with containers easier and then deploy and test the EventStoreDB container.

Configuring Portainer

When using Portainer, there are a few settings I like to configure before deploying containers, so I logged into Portainer using the admin account to make the changes.

Setting the Public IP

Portainer allows the user to connect to container ports by clicking on them. However, this behavior requires the setting of the Public IP for the environment. I clicked on the Environment tab and clicked on the local environment to bring up the Environment details page. I then entered the hostname in the Public IP textbox and clicked Update environment... button

Creating My User Account

Even in a home lab, I don't want to run Portainer as the admin user for everyday tasks. Instead, I want to use a user account with fewer privileges for working with containers and only use the admin account for doing maintenance tasks in Portainer.

First, I created a new user by opening the Users tab.

I entered my credentials in the Username and Password textboxes and clicked the Create user button.

Next, I added the new user to the local environment by going to the Environment tab and clicking the Manage access link.

On the Environment access page, I selected the cfarris user I just created, set the Role to Standard User, and clicked the Create access button.

With my user account now created, I logged out of Portainer as admin and logged back in on the new cfarris user account.

Deploying the EventStoreDB Container

The EventStoreDB documentation describes several different methods of deploying the database in a container ( My preference is to use Docker Compose and load the file directly from a GitHub repository. I like this approach because it moves the configuration files off of the Docker server and into source control where I can easily track and document changes.

Creating the GitHub Repository

First, I created a new repository in GitHub called eventstoredb-docker with a blank .gitignore file and a file.

Next, I created a branch and added the docker-compose.yml example from the EventStoreDB installation page.

version: "3.4"

    image: eventstore/eventstore:20.10.2-buster-slim
      - "1113:1113"
      - "2113:2113"
      - type: volume
        source: eventstore-volume-data
        target: /var/lib/eventstore
      - type: volume
        source: eventstore-volume-logs
        target: /var/log/eventstore


I committed the file and merged the branch into the master branch.

Deploying using Portainer

Next, I opened the Stacks page from the Portainer dashboard.

I clicked on Add stack to create open the Create stack page.

I entered eventstoredb as the name of my stack in the Name textbox. Portainer supports several methods for supplying the docker-compose.yml file but I'm using a GitHub repository so I selected Repository. Next, I entered the URL of my repository ( in the Repository URL textbox and checked the deployment was using the master branch for the Repository reference textbox and the docker-compose.yml file for the Compose path textbox.

Next, I scrolled to the bottom of the page and disabled Access control since I'm the only user working with the container.

Finally, I clicked Deploy the stack button to start the deployment.

Verifying the Deployment

I verified the deployment by opening the Containers page from the Portainer dashboard and clicking on the 2113-2113 link in the Published Ports column for the eventstoredb-eventstore.db-1 container to bring up the EventStoreDB dashboard.

Writing to the Database

I then created a NET Core console application to write some events to the database using the EventStoreDB documentation (

using System.Text.Json;
using EventStore.Client;

var settings = EventStoreClientSettings.Create("esdb://");
var client = new EventStoreClient(settings);

var testEvent = new TestEvent(EntityId: Guid.NewGuid().ToString("N"), $"Test Message {DateTimeOffset.Now}");
var eventData = new EventData(Uuid.NewUuid(), nameof(TestEvent), JsonSerializer.SerializeToUtf8Bytes(testEvent));
var cancellationToken = new CancellationToken();

await client.AppendToStreamAsync(
    new[] { eventData},
    cancellationToken: cancellationToken);

public record TestEvent(string EntityId, string Message);

I ran the console program a few times to generate several events then verified the events were being written to the EventStoreDB database using the Stream Browser page.

Next Steps

With the EventStoreDB database deployed, I now need to move some containers from my old Docker server to the new Docker server to take advantage of the newer hardware.

  • TeamCity Build Agents

  • Postgres Server

  • pgAdmin Tool