June 30, 2020

[Note] DB2 in Docker

Before moving to Ubuntu, I set up DB2 in VBox on Win10 + Ubuntu 18 VM.
https://blog.keithkim.com/2020/02/note-install-db2-express-c-on-ubuntu-18.html

With Ubuntu + Docker -- things are a lot easier.  See below:

Steps


[1] Get DB2 docker image

$ docker pull ibmcom/db2


[2] Create database volume directory

$ mkdir -p /data/db/db2


[3] Run DB2

$ docker run -itd --name db2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=<choose an instance password> -e DBNAME=testdb -v /data/db/db2:/database ibmcom/db2



[4] Monitor

$ docker logs -f db2

Wait until DB2 is running and database is created.


Misc

Connect to DB2 container:

$ docker exec -ti db2 bash -c "su - db2inst1"



REFERENCE

No comments: