DB/2: Using Docker Compose for IBM DB/2

DB/2: Using Docker Compose for IBM DB/2

Many years ago, at the beginning of my IT carreer, I was a member of the software support (and hotline) for an ERP software. The main database system was (and still is) Oracle, but we supported also Microsoft SQL Server, IBM DB/2 and Informix.

DB/2 was always a little bit strange to me, as it felt completely different from what I new as an Oracle DBA.

Additionally, DB/2 is different on these 2 platforms:

  • DB/2 LUW (Linux, Unix, Windows)
  • DB/2 z/OS (on Mainframe)
  • IBM AS/400 - iSeries i5 - IBM System i5 (DB/2 is integrated within the Operating System)

I don't know why you would need a DB/2 container, but maybe you have to configure a heterogenous database access or migrate from DB/2 to another RDBMS. Creating a DB/2 container would create a test environment for that.

The docker-compose.yml

IBM moved their containers from Docker Hub to their own registry: icr.io (IBM Container Registry). On Docker Hub, there would exist only older images.

This is the file:

services:
  db2instance:
    #    image: ibmcom/db2
    image: icr.io/db2_community/db2
    build:
      context: ./imageBuild
      args:
        INSTALLATION_FILE: ./db2-installation-file.tar.gz
        ACCEPT_LICENCE: ACCEPT
    privileged: true
    ports:
      - "58885:50000"
    volumes:
      ## mount both volumes '/var/ibm/db2' and '/home'
      ## to keep the data persistent for container-rebuilds/reboots
      - ./db2-inst:/var/ibm/db2
      - ./db2-home:/home
      ## the path '/data' is used for importing/exporting db2-data
      ## the files are backups of folders '/var/ibm/db2' and '/home'
      - ./backups:/data
    environment:
      - DB_NAME=MYDATABASE
      - DB_USER=db2user
      - DB_PASSWORD=db2password
      - STARTUP_MODE=restoreIfNotExists
      - DB_BACKUP=wdemo.tar.gz
      - LICENSE=accept

As the software is quite large, pulling the image takes some time:

# docker compose pull

Please keep in mind that you need a x86_64 platform to use this image.

As the container configures and starts the DB/2 instance, this also needs time:

# docker compose up -d
db2instance-1  | (*) Previous setup has not been detected. Creating the users...
db2instance-1  | (*) Creating users ...
db2instance-1  | (*) Creating instance ...
db2instance-1  | DB2 installation is being initialized.
db2instance-1  |
db2instance-1  |  Total number of tasks to be performed: 4
db2instance-1  | Total estimated time for all tasks to be performed: 309 second(s)
db2instance-1  |
db2instance-1  | Task #1 start
db2instance-1  | Description: Setting default global profile registry variables
db2instance-1  | Estimated time 1 second(s)
db2instance-1  | Task #1 end
db2instance-1  |
db2instance-1  | Task #2 start
db2instance-1  | Description: Initializing instance list
db2instance-1  | Estimated time 5 second(s)
db2instance-1  | Task #2 end
db2instance-1  |
db2instance-1  | Task #3 start
db2instance-1  | Description: Configuring DB2 instances
db2instance-1  | Estimated time 300 second(s)
db2instance-1  | Task #3 end
db2instance-1  |
db2instance-1  | Task #4 start
db2instance-1  | Description: Updating global profile registry
db2instance-1  | Estimated time 3 second(s)
db2instance-1  | Task #4 end
db2instance-1  |
db2instance-1  | The execution completed successfully.
db2instance-1  |
db2instance-1  | For more information see the DB2 installation log at "/tmp/db2icrt.log.106".
db2instance-1  | DBI1446I  The db2icrt command is running.
db2instance-1  |
db2instance-1  |
db2instance-1  | DBI1070I  Program db2icrt completed successfully.
db2instance-1  |
db2instance-1  |
db2instance-1  | (*) Fixing /etc/services file for DB2 ...
db2instance-1  | 01/14/2025 14:37:51     0   0   SQL1032N  No start database manager command was issued.
db2instance-1  | SQL1032N  No start database manager command was issued.  SQLSTATE=57019
db2instance-1  | (*) Cataloging existing databases
db2instance-1  | ls: cannot access '/database/data/db2inst1/NODE0000': No such file or directory
db2instance-1  | (*) Applying Db2 license ...
db2instance-1  | LIC1407N  You are trying to register an invalid license certificate file, "/var/db2_setup/include/db2dec.lic".
db2instance-1  | (!) There was a failure while applying the Db2 license ...
db2instance-1  | (*) Updating DBM CFG parameters ...
db2instance-1  | DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
db2instance-1  | successfully.
db2instance-1  | DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
db2instance-1  | successfully.
db2instance-1  | DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
db2instance-1  | successfully.
db2instance-1  | No Cgroup memory limit detected, instance memory will follow automatic tuning
db2instance-1  | (*) Remounting /database with suid...
db2instance-1  |
db2instance-1  | DB2 State : Operable
db2instance-1  | DB2 has not been started
db2instance-1  | Starting DB2...
db2instance-1  |
db2instance-1  | 01/14/2025 14:38:27     0   0   SQL1063N  DB2START processing was successful.
db2instance-1  | SQL1063N  DB2START processing was successful.
db2instance-1  | ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
db2instance-1  | (*) All databases are now active.
db2instance-1  | (*) Setup has completed.
db2instance-1  | false
db2instance-1  |
db2instance-1  | 2025-01-14-14.38.27.397667+000 I29960E393            LEVEL: Warning
db2instance-1  | PID     : 13949                TID : 125090709157376 PROC : db2start
db2instance-1  | INSTANCE: db2inst1             NODE : 000
db2instance-1  | HOSTNAME: 43768b91b43b
db2instance-1  | FUNCTION: DB2 UDB, base sys utilities, sqleReleaseStStLockFile, probe:16130
db2instance-1  | MESSAGE : Released lock on the file:
db2instance-1  | DATA #1 : String, 50 bytes
db2instance-1  | /database/config/db2inst1/sqllib/ctrl/db2strst.lck
db2instance-1  |
db2instance-1  | 2025-01-14-14.43.29.204454+000 I30354E621            LEVEL: Event
db2instance-1  | PID     : 14048                TID : 127013931181632 PROC : db2sysc 0
db2instance-1  | INSTANCE: db2inst1             NODE : 000
db2instance-1  | APPHDL  : 0-7
db2instance-1  | HOSTNAME: 43768b91b43b
db2instance-1  | EDUID   : 22                   EDUNAME: db2agent (instance) 0
db2instance-1  | FUNCTION: DB2 Common, Cryptography, cryptContextRealInit, probe:2735
db2instance-1  | DATA #1 : String, 37 bytes
db2instance-1  | CPU flags(string): 0xfff83203078bfbff
db2instance-1  | DATA #2 : String, 37 bytes
db2instance-1  | CPU flags(Uint64): 0xFFF83203078BFBFF
db2instance-1  | DATA #3 : String, 41 bytes
db2instance-1  | AES hardware acceleration detected: AESNI
db2instance-1  | DATA #4 : String, 48 bytes
db2instance-1  | Hardware random number generator detected: RdRnd

The database is now accessible using the port 58885.

Subscribe to Martin's Blog

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe