So you want Dockerize …DB2? So did I

IBM® Db2® is a multi-workload database designed to help you quickly develop, test and build applications for your business. Designed for operational and analytic workloads. IBM® Db2® Developer-C edition is a full feature, free version for non-production environments. Ideal for developers.


Install and run Db2 Developer-C Edition v11.1.3.3 using Docker and containers running CentOS. The image tag is now


  • Latest: Db2 v11.1 Mod Pack 3 Fix Pack 3 iFix001
  • Db2 HADR Support
  • Multi-platform support- x86_64, ppc64le, s390x


  • Docker engine
  • Directory/filesystem for persistent storage (<db storage dir>)

Getting Db2 Developer-C image

  1. Login into repository:
     docker login 
     User: <docker id>
     Password: <docker password>
  2. Pull the db2server image:
    For, we support 3 different architectures. Their respective docker pull commands are:
    docker pull store/ibmcorp/db2_developer_c:
    docker pull store/ibmcorp/db2_developer_c:
    docker pull store/ibmcorp/db2_developer_c:

    • Previous version tags:, and

Setting up and running containers

  1. Below is an example configuration. Save it to an .env_list and edit it if you wish.


    • LICENSE is to agree to the terms and conditions of the Db2 software contained in this image
    • DB2INSTANCE is to specify the Db2 Instance name
    • DB2INST1_PASSWORD is to specify the respective Db2 Instance Password
    • DBNAME creates an initial database with the name provided or leave empty if no database is needed
    • BLU can be set to true to enable BLU Acceleration for instance
    • ENABLE_ORACLE_COMPATIBILITY can be set to true to enable Oracle Compatibility on the instance
    • UPDATEAVAIL can be set to yes if there is an existing instance and running a new container with a higher Db2 level. Will be deprecated on next release
    • TO_CREATE_SAMPLEDB can be set to true to create a sample (pre-populated) database
    • REPODB can be set to true to create a Data Server Manager repository database
    • set IS_OSXFS=true if you are running on macOS
    • PERSISTENT_HOME is true by default, only specify to false if you are running Docker for Windows
    • HADR_ENABLED if set to true, Db2 HADR will be configured. The following three env variables depend on HADR_ENABLED to be true
    • ETCD_ENDPOINT is for specifying your own provided ETCD key-value store. Enter your endpoints with a comma as the delimiter and without a space. This env variable is needed if HADR_ENABLED is set to true
    • ETCD_USERNAME specify the username credential for ETCD. If empty, it will use your Db2 instance
    • ETCD_PASSWORD specify the password credential for ETCD. If empty, it will use your Db2 instance password
  2. docker run -h db2server_<your_container_name> \
            --name db2server --restart=always \  
            --detach \  
            --privileged=true \
            -p 50000:50000 -p 55000:55000 \
            --env-file .env_list \ 
            -v <db storage dir>:/database \
            <image name> 
    • where <db storage dir> is an existing local directory and .env_list is a collection of environment variables.
  3. After the docker run command is executed, a duration will be required until completion. User may run docker logs -f <your_container_name> to tail the docker entry point script. To confirm Db2 container is ready, in the logs we will see the message Setup has completed.
  4. Log on to the container:
     docker exec -ti db2server_<your_container_name> bash -c "su - ${DB2INSTANCE}"
    • where ${DB2INSTANCE} is the name of the instance user used during docker run.

Running Db2 HADR


  • Two Db2 Developer-C Edition containers running preferably on different servers. One will automatically configured to be the primary, and the other will be the standby. The takeovers will happen accordingly.
  • An additional shared volume mount -v <hadr storage dir>:/hadr between the two Db2 Docker deployments. An NFS server could be used as an example.
  • Include –ipc=host, –net=host in the docker run command and of course the HADR environment variables mentioned above.
  • Most importantly: You must have your own ETCD distributed key-value store which will be the two Db2 containers source of truth in the event one container goes down. Our governor that resides in both Db2 Docker containers must be able to communicate with the ETCD endpoints provided.

An example docker run command to include HADR:
docker run --name db2server --restart=always --privileged --ipc=host -p 50000 -p 55000 --env-file .env_list -v /home/db2server_fs/database:/database -v /home/db2server_fs/shared:/hadr -e HADR_ENABLED=true --net=host store/ibmcorp/db2_developer_c:

In the event we lose one of the containers, the user must manually start back up the container so the two Db2 containers can HADR connect once again.

Share your try below!


Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do

Você está comentando utilizando sua conta Sair /  Alterar )

Foto do Google

Você está comentando utilizando sua conta Google. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s