OLD - 2. Prepares the environment to create a DB2 instance on an existing DB2 installation
10K+
Try the new set of images: db2-install, db2-db2inst1 or db2-sample
Dockerfile linksIBM DB2 is a family of database server products developed by IBM. These products all support the relational model, but in recent years some products have been extended to support object-relational features and non-relational structures, in particular XML.
Historically and unlike other database vendors, IBM produced a platform-specific DB2 product for each of its major operating systems. However, in the 1990s IBM changed track and produced a DB2 "common server" product, designed with a common code base to run on different platforms.

A DB2 instance is a running process that controls the security at the higher level, listens on a specific port, controls the databases it hosts, and many other operations related to database administration.
This image is part of a set of images to create your DB2 environment:
This is the stack of images:
+----------------+
| db2-sample | <-- Sample database (db2sampl)
+----------------+
| db2inst1 | <-- Default instance created (db2inst1:50000)
+----------------+
| db2-instance | <-- Environment to create an instance
+----------------+
| db2-install | <-- DB2 Express-C installed
+----------------+
This image will prepare the environment to create a DB2 instance. It uses the angoca/db2-install image that installs DB2.
Once the installation was done, this image could be loaded. This image will populate the previous image with some scripts to ease the instance creation. The script that creates the instance follows the instructions of a response file. The instance by default is db2inst1 listening on port 50000 installed in the /home/db2inst1 directory.
The process is performed in two steps:
Please, check the Travis-CI execution to see how this image is build.
The build process can be done via a pull or directly from the sources via build. This will create the image that will be ready to run.
Pull from Docker:
sudo docker pull angoca/db2-instance:latest
Build from sources
git clone https://github.com/angoca/db2-docker.git
sudo docker build instance/expc
The execution of a new container should be done in privilege mode, interactive with a seudo TTY. For example:
sudo docker run -i -t --privileged=true --name="db2inst1" -p 50000:50000 angoca/db2-instance
The name of the container will be db2inst1.
You can try the following line in order to not use privileged mode:
sudo docker run -i -t --ipc="host" --cap-add IPC_LOCK --cap-add IPC_OWNER --name="db2inst1" -p 50000:50000 angoca/db2-instance
Once the container is running, the console is active under the /tmp/db2_conf directory. In this directory you will find a DB2 response file and a script to create an instance. The DB2 response file is configured to create a DB2 instance called db2inst1 listening on port 50000. If you want to change these or other properties, you just need to modify the response file or call the createInstance script with another username, for example:
./createInstance
Or for a specific instance name
./createInstance myinst
It will run db2isetup, and then you can change to the instance user and start the instance. Once there, you can create the database, or perform other configuration changes.
Once you have finished the configuration, you can leave the container running by typing:
Ctrl + P + Q
If you want to have an independent execution environment, but a shared storage, you can mount a local directory in the images. It is recommended that you mount the /home directory and create all instances under this structure. This will store the home directories of the instances in the host, instead of in the containers.
/home <-- /db2 locally in the host
/db2inst1 <-- Home directory for instance db2inst1
/db2inst2 <-- Home directory for instance db2inst2
The previous distribution works only if you create different instance users across all containers. (It is not necessary to have one instance per container, but different instances across all containers when using host storage.)
It is very important that you mount this file system before creating the instance.
sudo mkdir /db2
sudo docker run -i -t --privileged=true --name="db2inst1" -p 50000:50000 -v /db2:/home angoca/db2-instance
NOTE: If you use automatic storage in DB2, and the database creation does not specify any path, the data will be also stored under /home. Instead, if you specify specific paths for your containers, make sure where they are stored (in the containers or in the host via mount).
Once the instance has been created, you can run the DB2 instance as a Docker daemon.
sudo docker start
Once the container with DB2 is running, it can be used to create, populate, manipulate and perform other activities with databases.
If you want to access the console, you need to do an attach to the container
sudo attach db2inst1
The design of this image is based on the following DB2-Docker images:
And the posts of the following blogs:
The advantages to use this image instead of the other are:
db2inst1 or something like db2instX where X is a number.angoca repository. The image is not created on the fly. The basic images are created from Dockerfiles, the other were published in the repository with the instance or database already created. As part of the publish, a corresponding documentation is provided.If you have any problems with or questions about this image, please contact us through a GitHub issue.
You can also reach the mainteiner via Twitter @angoca.
You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.
Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
Content type
Image
Digest
Size
509.7 MB
Last updated
about 8 years ago
Requires Docker Desktop 4.37.1 or later.