Db2 (On Premises and Cloud)

Expand all | Collapse all

db2 docker persistent volume

  • 1.  db2 docker persistent volume

    Posted Wed August 11, 2021 03:30 AM
    as a specific user is having a problem to create a database in a docker environment on windows he requested me to create the database on a persistent volume on my machine (where it worked) and shipping him this volume
    is there any documentation on how to proceed for a persistent volume in a docker container/environment  ?
    as db2 is creating files in different location, will this be useful (to  ship the persistent volume) and do we have to create the instance/db with specific options ?
    dbpath on - on - .... to have all on this volume ?
    any link to any doc would be helpful


    ------------------------------
    Thank for all update/help
    Best Regards, Guy Przytula
    ------------------------------


  • 2.  RE: db2 docker persistent volume

    Posted Thu August 12, 2021 03:20 AM
    Hi Guy,

    at first: a persistent volume in docker is not the same as virtual volume in a vm. its not an iso / file that can easily be "shipped".

    to export/ship/import a volume you can go through the following steps (docker as root and same docker host OS - remember to set you env varas correct if running db2 in docker on windows):
    1) Export to a tar archive (<MyDb2SourceContainer> should be stopped already)
    docker run --rm --volumes-from <MyDb2SourceContainer> -v $(pwd):/backup busybox tar cvf /backup/backup.tar /database
    2) transfer you backup.tar to target machine
    3) create (not run) new db2 container with new volume (instance user and dbname has to be the same as in source image -> db2inst1)
    docker create -v <mynewvolume>:/database --name <MyNewDb2Container> ..... ibmcom/db2:latest
    4) import tar archive to new volume
    docker run --rm --volumes-from <MyNewDb2Container> -v $(pwd):/backup busybox tar xvf /backup/backup.tar
    database/
    
    5) start db2 container
    docker start <MyNewDb2Container>


    ------------------------------
    Markus Fraune
    ------------------------------



  • 3.  RE: db2 docker persistent volume

    Posted Thu August 12, 2021 04:10 AM
    many thanks for the info
    has been tested/done


    ------------------------------
    Thank for all update/help
    Best Regards, Guy Przytula
    ------------------------------