Db2

Db2

Where DBAs and data experts come together to stop operating and start innovating. Connect, share, and shape the AI era with us.


#Data


#Data
#Databases
#Operatingsystems
#Db2
#Databasesolutions
 View Only
Expand all | Collapse all

Db2 12.1.2 with Docker on Windows (WSL)

  • 1.  Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/11/25 06:58 AM

    Hello Community,

    Does anybody has the same issue with Db2 12.1.2 with Docker on Windows (WSL)?

    The first run with Db2 works fine until I restart the Container:

    docker run -h db2server --name db2server --restart=always --detach --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INSTANCE=myuser -e DB2INST1_PASSWORD=mypw -e DBNAME=sample -e SAMPLEDB -v db2data:/database icr.io/db2_community/db2:latest

    Stoping and starting the Container occurred with following message and is looping with running db2support command:

    025-06-11 12:12:19 (!) There was a problem configuring the instance. Copying over logs and traces to /database/config ...

    2025-06-11 12:12:19 mkdir: cannot create directory '/database/config/db2icrt': File exists

    Unfortunately no more information.

    Best regards, Joachim



    ------------------------------
    Joachim Müller
    ------------------------------


  • 2.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/11/25 07:47 AM

    Hello.

    I have the same with docker on linux.
    Seems, that it runs a new installation erroneously every time on container start.
    Bad container action design.
    I saw the same when I removed 12.1.1 container and pulled a new 12.1.2 image.
    Now my container restarts in a loop.

    docker logs after stop/start of the container:

    (*) Restoring global registry file ...
    (*) Preparing the environment before updating the instance ...
    (*) Fixing /etc/services file for DB2 ...
    (*) Fixing db2nodes file configuration ...
    (*) Creating instance ...
    DB2 installation is being initialized.


     Total number of tasks to be performed: 4
    Total estimated time for all tasks to be performed: 309 second(s)


    Task #1 start
    Description: Setting default global profile registry variables
    Estimated time 1 second(s)
    Task #1 end


    Task #2 start
    Description: Initializing instance list
    Estimated time 5 second(s)
    Task #2 end


    Task #3 start
    Description: Configuring Db2 instances
    Estimated time 300 second(s)
    Task #3 end


    Task #4 start
    Description: Updating global profile registry
    Estimated time 3 second(s)
    Task #4 end


    A minor error occurred during the execution.


    For more information see the DB2 installation log at "/tmp/db2icrt.log.844".
    DBI1446I  The db2icrt command is running.


    DBI1264E  This program failed. Errors encountered during execution were
          written to the installation log file. Program name:
          db2icrt. Log file name: /tmp/db2icrt.log.844.


    Explanation:


    This message is returned when some processes and operations have failed.
    Detailed information about the error was written to the log file.


    User response:


    Contact IBM support to get assistance in resolving this issue. Keep the
    log file intact as this file is an important reference for IBM support.


       Related information:
       Contacting IBM Software Support


    (!) There was a problem configuring the instance. Copying over logs and traces to /database/config ...


                  _______   D B 2  S u p p o r t   ______


    This program generates information about a DB2 server, including information
    about its configuration and system environment. The output of this program
    is stored in a file named 'db2support.zip'. If possible, run this program
    while the problem is occurring.


    For the most complete output, this utility should be invoked with root
    authority. Users with more limited privileges on the system can run this tool,
    however, some of the data collection actions will result in reduced reporting
    and reduced output.


    Output file is "/database/config/db2icrt/db2support.zip"
    Time and date of this collection: 2025-06-11-11.30.51.948473


    Creating directory /database/config/db2icrt/DB2SUPPORT
    Starting collection on host db2-12_1
     Creating directory /database/config/db2icrt/DB2SUPPORT/db2-12_1_IIH
    Collecting resources group information
       The following file was not found or could not be executed during diagnostic
       data collection: /usr/bin/lssam
       The following file was not found or could not be executed during diagnostic
       data collection: /usr/bin/lsrsrc
       The following file was not found or could not be executed during diagnostic
       data collection: /usr/bin/lsrsrc
    Collecting user identity information
    Collecting current process information
    Collecting active interprocess communications facilities information
    Collecting system information
    Collecting detailed data on system and hardware errors
       The following file was not found or could not be executed during diagnostic
       data collection: /usr/bin/errpt
    Collecting registry contents
    Collecting GPFS information
       The following file was not found or could not be executed during diagnostic
       data collection: /usr/lpp/mmfs/bin/gpfs.snap
    Collecting configuration, log and trace information for RSCT
       The following file was not found or could not be executed during diagnostic
       data collection: /usr/bin/ctsnap
    Collecting information about installed DB2 products
    Collecting information about state of db2 instance
    Collecting information about DB2 product prerequisites
    Collecting /etc/services
    Collecting /database/config/db2inst1/sqllib/db2nodes.cfg
    Collecting /tmp/db2icrt.log.108
    Collecting /tmp/db2icrt_local.log.4831
    Collecting /tmp/db2icrt.log.844
    Collecting directory /database/config/db2inst1/sqllib/db2dump
    Collection on host db2-12_1 completed
    Compressing files in /database/config/db2icrt/DB2SUPPORT directory
    Collecting /database/config/db2icrt/db2support.log
    Collecting db2support.out


    db2support is now complete.
     An archive file has been produced: "/database/config/db2icrt/db2support.zip"


    "15" warnings found during db2support collection



    ------------------------------
    Mark Barinstein
    ------------------------------



  • 3.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/11/25 07:53 AM

    Hello Mark,

    So I'm not alone...

    That's sad. Let's hope that IBM or the builder of the container will solve the problem shortly.

    Best regards, Joachim



    ------------------------------
    Joachim Müller
    ------------------------------



  • 4.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/16/25 11:28 AM

    The problem is that the following command runs every time a container is started.

    ${DB2DIR?}/instance/db2icrt -update-instance-if-exists -u ${FENCED_USER?} ${DB2INSTANCE?}

    I'm not sure what it does internally with this undocumented `-update-instance-if-exists` flag or if this flag is a culprit of the problem, but it seems that it sets wrong permissions on the following file:

    # ls -l /database/config/db2inst1/sqllib/adm/fencedid
    -rw-r--r-- 1 root root 31 Jun 11 13:05 /database/config/db2inst1/sqllib/adm/fencedid

    and if the same command runs again (on the container restart, for example), it returns non-zero code with the following message:

    ERROR: DBI20187E  The fencedid file "/database/config/db2inst1/sqllib/adm/fencedid" is invalid because it is not owned by the "root":"db2iadm1". Change the ownership of the fencedid file to be owned by the "root":"db2iadm1" and then rerun the command.
    ERROR: An error occurred while configuring the instance "db2inst1".

    So, if you want this funny rifle to shoot more than once, then you should manually set the corresponding permissions on a stopped container like this:

    sudo docker run --rm -v database:/database --entrypoint /bin/bash icr.io/db2_community/db2 -c "chown root:1000 /database/config/db2inst1/sqllib/adm/fencedid"

    Or don't forget to run this `chown` inside the running container (as root) after its successful startup.



    ------------------------------
    Mark Barinstein
    ------------------------------



  • 5.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/18/25 02:45 AM

    In the meantime I open a case and IBM Support has tested and encountered the same problem, They have engaged the area experts to check on this behavior.

    Best regards, Joachim



    ------------------------------
    Joachim Müller
    ------------------------------



  • 6.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/18/25 06:01 AM

    It would be good to inform IBM, that v12.1.2 db2iupdt / installFixPack still fail on systems with:

    $ sudo sysctl fs.protected_regular
    fs.protected_regular = 2

    For example:

    $ sudo /tmp/server_dec/installFixPack -n -y -b /opt/ibm/db2/V12.1/
    Missing value for token[1].
    DBI1017I installFixPack is updating the base Db2 installation, located
         in /opt/ibm/db2/V12.1/ and is applying the new fix pack to s.
    A minor error occurred during the execution.
     
    For more information see the DB2 installation log at
    "/tmp/installFixPack.log.154409".
    and the log file contains:
    ...
    Installing: GUARDIUM_INST_MNGR_CLIENT
     
    Updating Db2 file sets :.......Success
    Executing control tasks :.......Success
    Updating global registry :.......Success
    Starting Db2 Fault Monitor :.......Success
    Updating the db2ls and db2greg link :.......Success
    ERROR: DBI1084E  An attempt to create /home/db2inst1/sqllib/ctrl/.fencedID failed.
     
    Explanation:
     
    An error occurred when creating the given file or directory.
     
    User response:
     
    Check that there is enough space in the file system and that you have
    write permission for the required directory. Suggested directory
    permissions are u=rwx,go=rx.
     
     
    ERROR: An error occurred while updating the instance "db2inst1". The return
    value is "5370".  Run the command "/opt/ibm/db2/V12.1/instance/db2iupdt" to
    update this instance after the install completes. If the problem persists
    contact your technical service representative.
    ...
    Root can't write to this file on such systems:
    $ ls -ld  ~db2inst1/sqllib/ctrl
    drwxrwsr-t 2 db2inst1 db2iadm1 4096 Jun 18 12:38 /home/db2inst1/sqllib/ctrl
    $ echo db2fenc1 | sudo tee ~db2inst1/sqllib/ctrl/.fencedID
    tee: /home/db2inst1/sqllib/ctrl/.fencedID: Permission denied
    db2fenc1
    The workaround which db2iupdt still doesn't use is:
    $ sudo sysctl -w fs.protected_regular=0
    fs.protected_regular = 0
    $ echo db2fenc1 | sudo tee ~db2inst1/sqllib/ctrl/.fencedID
    db2fenc1
    $ sudo /opt/ibm/db2/V12.1/instance/db2iupdt db2inst1
    ...
    The execution completed successfully.
    $ sudo sysctl -w fs.protected_regular=2
    fs.protected_regular = 2


    ------------------------------
    Mark Barinstein
    ------------------------------



  • 7.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 04/05/26 09:18 AM

    Hi everyone,

    I've encountered the same fencedid ownership issue and have been working around it by running the following command while the container is running:

    docker exec -it db2server chown root:db2iadm1 /database/config/db2inst1/sqllib/adm/fencedid
    

    (I'm using Podman, but the same approach should work with Docker.)

    This corrects the ownership that gets broken during the container restart process. Hope this helps until a proper fix is released.



    ------------------------------
    KAZUHISA MISONO
    Data Platform Technical Specialist
    IBM Japan
    ------------------------------



  • 8.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 11/07/25 10:36 AM

    Hello Community,

    I had the same issue on Windows (WSL) and also on Ubuntu. The container works fine on the first run, but on restart, DB2 fails to authenticate due to security-related file permissions (SQL1639N), and db2support loops endlessly.

    After hours of debugging, I finally got a working solution by adjusting the entrypoint in my Docker Compose file. The key points are:

    • Cleaning potentially corrupted files (fencedid and dasid) from previous runs.

    • Correcting ownership and permissions for /database, /database/config/db2inst1/sqllib, and /database/config/db2inst1/sqllib/security.

    • Ensuring fencedid is owned by root:db2iadm1 with 644 permissions.

    • Automatically creating the database if it does not exist.

    • Waiting for DB2 to be fully ready before allowing the container to report healthy.

    Here is the essential part of my entrypoint that finally worked:

    if [ -f /database/config/db2inst1/sqllib/adm/fencedid ]; then
      rm -f /database/config/db2inst1/sqllib/adm/fencedid
      rm -f /database/config/db2inst1/sqllib/adm/dasid
    fi
    chown root:db2iadm1 /database/config/db2inst1/sqllib/adm/fencedid
    chmod 644 /database/config/db2inst1/sqllib/adm/fencedid
    chmod 700 /database/config/db2inst1/sqllib/security
    find /database/config/db2inst1/sqllib/security -type f -exec chmod 600 {} \;

    After implementing this, DB2 starts correctly after container restarts and my applications can connect without SQL1639N errors.

    I hope this helps anyone struggling with DB2 Docker container restarts on Windows/WSL.

    Best regards,
    Ignacio



    ------------------------------
    Ignacio Ainol Rivera
    ------------------------------



  • 9.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 11/14/25 07:55 AM

    On the first four lines you remove fencedid if it exists, then on lines 5 and 6 you try to chown and chmod it ?



    ------------------------------
    José Pina Coelho
    IT Specialist at Kyndryl
    ------------------------------



  • 10.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 11/14/25 09:25 AM
    Edited by Mark Barinstein 11/14/25 09:27 AM

    For those who are still interesting...

    Nothing changed with the db2 12.1.3 image.
    Every container start corrupts group ownership of the `~db2inst1/sqllib/adm/fencedid` file.

    The easiest way to repair it is to change the corresponding group ownership before/after every container start.
    It's possible to do this from outside of the container as well.

    So, if you see something like this:

    $ ls -l --time-style=+"" database/config/db2inst1/sqllib/adm/fencedid
    -rw-r--r-- 1 root root 31  database/config/db2inst1/sqllib/adm/fencedid

    you may change it with the following from your host (1000 is an ID of the db2iadm1 group in the container):

    $ sudo chgrp 1000 database/config/db2inst1/sqllib/adm/fencedid


    # The result must be as follows afterwards
    $ ls -ln --time-style=+"" database/config/db2inst1/sqllib/adm/fencedid
    -rw-r--r-- 1 0 1000 31  database/config/db2inst1/sqllib/adm/fencedi

    ------------------------------
    Mark Barinstein
    ------------------------------



  • 11.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 11/14/25 10:19 AM

    Thanks Mark. Nothing changed the same as before. This happens when I update the Db2 container from 12.1.2 to 12.1.3.

    SQL1103W  The UPGRADE DATABASE command was completed successfully.
    -bash: line 1: db2updv115: command not found

    Best regards, Joachim



    ------------------------------
    Joachim Müller
    ------------------------------



  • 12.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 11/14/25 11:38 AM

    Joachim, for Db2 V12.1.* I would look for db2updv121 - not db2updv115 ...



    ------------------------------
    Jan Nelken
    Db2 (LUW) DBA
    Open for work
    Katowice or Krakow
    +48 783 109 863
    ------------------------------



  • 13.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 11/14/25 12:32 PM

    Hello Jan,

    I know, but not IBM.

    Best regards, Joachim



    ------------------------------
    Joachim Müller
    ------------------------------



  • 14.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 03/31/26 09:51 AM

    Hi everyone, unfortunately, the problem in Db2 V12.1.4 still doesn't seem to be fixed. What a disgrace from IBM! I wanted to show the container to our students, but compared to the PostgreSQL container, Db2 won't stand a chance. The container is huge and can only be used once.

    Do you think it would be worthwhile to open another ticket with IBM to fix the file permission issue?

    Best regards, Michael



    ------------------------------
    Michael Kühnel
    ------------------------------



  • 15.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/25/26 11:22 AM

    Hello Everyone

    Thanks so much for reporting the issue. This has been resolved in the latest icr.io/db2_community/db2 image, tagged with both `icr.io/db2_community/db2:12.1.5.0` as well as `icr.io/db2_community/db2:latest`. The container should now be able to gracefully restart and continue operation

    Regards,

    Mohamed Bengezi



    ------------------------------
    Mohamed Bengezi
    ------------------------------



  • 16.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/29/26 07:00 AM

    Hello Mohamed,

    The 12.1.5 container fails to start on an earlier level instance (12.1.3 in my case) with the following message:

    MESSAGE : Executables and shared libraries are from different builds

    Look at the following commands inside the container:

    [db2inst1@db2-12-1 ~]$ db2gcf -s

    DB2 State : Operable


    [db2inst1@db2-12-1 ~]$ db2start
    06/29/2026 10:08:56     0   0   SQL1042C  An unexpected system error occurred.
    SQL1032N  No start database manager command was issued.  SQLSTATE=57019

    [db2inst1@db2-12-1 ~]$ db2diag -H 1m
    2026-06-29-10.08.56.400812+000 I482174077E1669       LEVEL: Event
    PID     : 2666                 TID : 139677343930176 PROC : db2start
    INSTANCE: db2inst1             NODE : 000
    HOSTNAME: db2-12-1
    FUNCTION: DB2 UDB, base sys utilities, sqleStartStopSingleNode, probe:1130
    DATA #1 : String, 45 bytes
    /database/config/db2inst1/sqllib/adm/db2star2
    DATA #2 : Hexdump, 256 bytes
    0x00007FFF359B4A90 : 2F64 6174 6162 6173 652F 636F 6E66 6967    /database/config
    0x00007FFF359B4AA0 : 2F64 6232 696E 7374 312F 7371 6C6C 6962    /db2inst1/sqllib
    0x00007FFF359B4AB0 : 2F61 646D 2F64 6232 7374 6172 3200 4E4F    /adm/db2star2.NO
    0x00007FFF359B4AC0 : 4D53 4700 0000 0000 0000 0000 0000 0000    MSG.............
    0x00007FFF359B4AD0 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4AE0 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4AF0 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B00 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B10 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B20 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B30 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B40 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B50 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B60 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B70 : 0000 0000 0000 0000 0000 0000 0000 0000    ................
    0x00007FFF359B4B80 : 0000 0000 0000 0000 0000 0000 0000 0000    ................

    2026-06-29-10.08.56.536794+000 I482175747E328        LEVEL: Severe
    PID     : 2668                 TID : 140475094964032 PROC : db2star2
    INSTANCE: db2inst1             NODE : 000
    HOSTNAME: db2-12-1
    FUNCTION: DB2 UDB, base sys utilities, DB2StartMain, probe:35
    MESSAGE : Executables and shared libraries are from different builds

    2026-06-29-10.08.56.537291+000 I482176076E333        LEVEL: Severe
    PID     : 2668                 TID : 140475094964032 PROC : db2star2
    INSTANCE: db2inst1             NODE : 000
    HOSTNAME: db2-12-1
    FUNCTION: DB2 UDB, base sys utilities, DB2StartMain, probe:0
    MESSAGE : ZRC=0x870F0104=-2029059836=RC_ENV_NOT_FOUND "Variable not found"

    2026-06-29-10.08.56.550153+000 I482176410E1178       LEVEL: Event
    PID     : 2666                 TID : 139677343930176 PROC : db2start
    INSTANCE: db2inst1             NODE : 000
    HOSTNAME: db2-12-1
    FUNCTION: DB2 UDB, base sys utilities, sqlePrintFinalMessage, probe:13673
    DATA #1 : unsigned integer, 4 bytes
    0
    DATA #2 : signed integer, 4 bytes
    1
    DATA #3 : SQLCA, PD_DB2_TYPE_SQLCA, 136 bytes
     sqlcaid : SQLCA     sqlcabc: 136   sqlcode: 0   sqlerrml: 0
     sqlerrmc:
     sqlerrp : SQL12015
     sqlerrd : (1) 0x00000000      (2) 0x00000000      (3) 0x00000000
               (4) 0x00000000      (5) 0x00000000      (6) 0x00000000
     sqlwarn : (1)      (2)      (3)      (4)        (5)       (6)
               (7)      (8)      (9)      (10)        (11)
     sqlstate:
    DATA #4 : SQLCA, PD_DB2_TYPE_SQLCA, 136 bytes
     sqlcaid : SQLCA     sqlcabc: 136   sqlcode: -1032   sqlerrml: 0
     sqlerrmc:
     sqlerrp : SQLESSSN
     sqlerrd : (1) 0x00000000      (2) 0x00000000      (3) 0x00000000
               (4) 0x00000000      (5) 0x00000000      (6) 0x00000000
     sqlwarn : (1)      (2)      (3)      (4)        (5)       (6)
               (7)      (8)      (9)      (10)        (11)
     sqlstate:

    2026-06-29-10.08.56.655800+000 I482177589E1266       LEVEL: Event
    PID     : 2666                 TID : 139677343930176 PROC : db2start
    INSTANCE: db2inst1             NODE : 000
    HOSTNAME: db2-12-1
    FUNCTION: DB2 UDB, base sys utilities, sqleIssueStartStop, probe:12057
    DATA #1 : SQLCA, PD_DB2_TYPE_SQLCA, 136 bytes
     sqlcaid : SQLCA     sqlcabc: 136   sqlcode: 0   sqlerrml: 0
     sqlerrmc:
     sqlerrp : SQL12015
     sqlerrd : (1) 0x00000000      (2) 0x00000000      (3) 0x00000000
               (4) 0x00000000      (5) 0x00000000      (6) 0x00000000
     sqlwarn : (1)      (2)      (3)      (4)        (5)       (6)
               (7)      (8)      (9)      (10)        (11)
     sqlstate:
    DATA #2 : SQLCA, PD_DB2_TYPE_SQLCA, 136 bytes
     sqlcaid : SQLCA     sqlcabc: 136   sqlcode: -1032   sqlerrml: 0
     sqlerrmc:
     sqlerrp : SQLEPFIN
     sqlerrd : (1) 0x00000000      (2) 0x00000000      (3) 0x00000000
               (4) 0x00000000      (5) 0x00000000      (6) 0x00000000
     sqlwarn : (1)      (2)      (3)      (4)        (5)       (6)
               (7)      (8)      (9)      (10)        (11)
     sqlstate:
    DATA #3 : Boolean, 1 bytes
    false
    DATA #4 : Boolean, 1 bytes
    false
    DATA #5 : Boolean, 1 bytes
    false
    DATA #6 : Boolean, 1 bytes
    false
    DATA #7 : Boolean, 1 bytes
    false

    2026-06-29-10.08.56.656391+000 I482178856E389        LEVEL: Warning
    PID     : 2666                 TID : 139677343930176 PROC : db2start
    INSTANCE: db2inst1             NODE : 000
    HOSTNAME: db2-12-1
    FUNCTION: DB2 UDB, base sys utilities, sqleReleaseStStLockFile, probe:16138
    MESSAGE : Released lock on the file:
    DATA #1 : String, 50 bytes
    /database/config/db2inst1/sqllib/ctrl/db2strst.lck

    I had to run this manually to make it work (with db2updv121 & all necessary update bind commands).

    /opt/ibm/db2/V12.1/instance/db2icrt -update-instance-if-exists -nosharedgroup -p 50000 -u db2fenc1 db2inst1

    It didn't want to run without the -nosharedgroup parameter. You break current update / upgrade scripts with this "feature"...

    Unusual behavior:
    db2ls shows the old db2 level - 12.1.3 even after successful execution of the command above!
    db2ls shows 12.1.5 after the db2start only!



    ------------------------------
    Mark Barinstein
    ------------------------------



  • 17.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/30/26 04:40 AM

    Mohamed,

    Just looked into the setup code in the container.

    /var/db2_setup/include/db2_common_functions:

    create_instance()
    {
       rc=${TRUE?}
       instance_exists=false
    
       # Check if instance is properly configured by verifying critical binaries exist
       if [ -f ${DB2INSTANCE_HOME?}/sqllib/db2profile ] && \
          [ -f ${DB2INSTANCE_HOME?}/sqllib/adm/db2start ]; then
         echo "(*) Instance already exists. Preparing the environment for restart ... "
         instance_exists=true
    ...
       # Only create/update instance if it doesn't exist yet or is incomplete
       if [ "$instance_exists" = false ]; then
         echo "(*) Creating instance ... "
    
         if ! ${DB2DIR?}/instance/db2icrt -update-instance-if-exists -u ${FENCED_USER?} -nosharedgroup ${DB2INSTANCE?}; then
            echo "(!) There was a problem configuring the instance. Copying over logs and traces to ${STORAGE_DIR?}/config ..."
    ...
            return ${FALSE?}
         fi
       else
         echo "(*) Skipping instance creation - instance already configured"
       fi
    ...
    }

    You run this function at every container start, and it seems that db2icrt runs when db2 instance is not created only.
    But db2icrt must run on every db2 fix pack update / release upgrade as well.

    Moreover:

    update_db2_code()
    {
       dbname=$1
    
       detect_upgrade ${dbname?}
       upgrade_or_update=$?
    
       if [[ $upgrade_or_update -eq 1 ]]; then
           echo "(*) Updating database ${dbname?} ..."
           su - ${DB2INSTANCE?} -c "db2start"
           su - ${DB2INSTANCE?} -c "db2updv115 -d ${dbname?}"
       elif [[ $upgrade_or_update -eq 2 ]]; then
           echo "(*) Upgrading database ${dbname?} ... "
           su - ${DB2INSTANCE?} -c "db2start"
           su - ${DB2INSTANCE?} -c "db2 catalog db ${dbname?} on ${DATA_DIR?}"
           su - ${DB2INSTANCE?} -c "db2 upgrade db ${dbname?} REBINDALL"
           su - ${DB2INSTANCE?} -c "db2updv115 -d ${dbname?}"
       else
           echo "(*) Code level is the same. No update/upgrade needed."
       fi
    
    }
    

    db2updv115??? There is no such an utility in the 12.1 release. Must be db2updv121 instead.


    I don't see any checks for /proc/sys/fs/protected_regular = 2 -> the same problems with the ~/sqllib/adm/fencedid file ownership probably.

    So, this image version may run good enough on new installations without updates / upgrades only...



    ------------------------------
    Mark Barinstein
    ------------------------------



  • 18.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/30/26 05:19 AM
    Mark,

    You wrote: " But db2icrt must run on every db2 fix pack update / release upgrade as well." Did you mean db2iupdt perhaps?






  • 19.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/30/26 06:15 AM
    Jan,
    > You wrote: " But db2icrt must run on every db2 fix pack update / release upgrade as well." Did you mean db2iupdt perhaps?
    No.
    It seems, that this cool undocumented -update-instance-if-exists parameter of db2icrt runs the corresponding db2iupdt / db2iupgrade under the hood depending on the current code & instance state correctly.
    Very useful and convenient parameter for upgrades in containers, since you are not able to run db2iupgrade manually, when you have a container with a new release and a db2 instance with an older release. It tries to check databases and returns some unavoidable errors. And you don't have the older code in the container.
    So, db2icrt -update-instance-if-exists is a single command for new installations, updates and upgrades.


    ------------------------------
    Mark Barinstein
    ------------------------------



  • 20.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/30/26 07:17 AM

    Thanks, Mark!

    I believe you should seriously consider writing a book "Undocumented Db2 features" - we all would benefit from it!



    ------------------------------
    Jan Nelken
    Db2 (LUW) DBA
    Open for work
    Katowice or Krakow
    +48 783 109 863
    ------------------------------



  • 21.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 06/30/26 08:47 AM

    Jan,

    Book writing on IBM technologies is too complex and time consuming. Especially for a person who doesn't work for IBM anymore. It's even not possible to access the most of technotes without a support contract (even the simplest "Recommended Fix Packs for DB2 for Linux, UNIX and Windows" article!)...

    But, for those who are interesting, I have a git repo with instructions for root & non-root DB2 images building, which one may use on their own using wide variety of base operating systems.
    I started this project because the official DB2 images (actually, all 12.1 mods including the latest one) have too many strange "features" making their use not very convenient for me...
    I don't have enough time to make it production ready (like proper error handling, thorough testing), but it passes basic testing with start, stop, updates, upgrades.
    There is no built-in support for a number of features like HADR, DPF, HA, TextSearch, but this can be customized with before & after db2 startup scripts.
    The root image can use existing data of the official DB2 containers.
    The non-root image doesn't contain DB2 code (it has much smaller size) and can run as non-privileged.

    https://github.com/mark-bb/db2-docker



    ------------------------------
    Mark Barinstein
    ------------------------------



  • 22.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 07/01/26 10:36 AM

    Thanks for reporting this Mark! We'll be pushing an updated image soon to address some of these issues



    ------------------------------
    Mohamed Bengezi
    ------------------------------



  • 23.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 07/06/26 01:41 PM

    Another "feature" of 12.1.5.

    Non-root installation.

    db2rfe returns DBI1250E "Applications are still using instance" on a stopped instance and refuses to work now.

    [root@967bcaf21e11 ~]# /database/config/db2inst1/sqllib/instance/db2iexec -n db2inst1 '/database/config/db2inst1/sqllib/bin/db2gcf -i db2inst1 -s'; echo $?
    0
    
    [root@967bcaf21e11 ~]# /database/config/db2inst1/sqllib/bin/db2gcf -i db2inst1 -s; echo $?
    Instance  : db2inst1
    DB2 State : Operable
    1

    The ~/sqllib/instance/db2rfe script uses the 1-st command in its chk_instance_stopped function, and this command returns 0 (incorrect) now, while it returned 1 previously.



    ------------------------------
    Mark Barinstein
    ------------------------------



  • 24.  RE: Db2 12.1.2 with Docker on Windows (WSL)

    Posted 07/13/26 02:14 PM

    An updated image has been pushed to `icr.io/db2_community/db2:12.1.5.0` and `icr.io/db2_community/db2:latest`. It should address most of your concerns here except for the db2rfe issue. We'll have to work with the appropriate teams to investigate. Thank you!



    ------------------------------
    Mohamed Bengezi
    ------------------------------