Thursday, February 23, 2017

DB2 Express C installation on Ubuntu 16.04 using Docker

Environment: Using Vagrant and Virtual Box

Open the terminal of your host machine.

Create a folder:


mkdir db2
cd db2

Initiate vagrant project using ubuntu 16.04 xenial64:


vagrant init ubuntu/xenial64









Vagrant up to spawn the VM


vagrant up --provider virtualbox












Machine starts.

To login into the VM:

vagrant ssh














You will be logged in as ubuntu user.

To install Docker, follow this link.

After docker is successfully installed, run the following command to check whether it is properly installed or not:

docker ps

this will list the docker processes running on your VM.

Start the container:

sudo docker run -it -p 50000:50000 -e DB2INST1_PASSWORD=db2inst1-pwd -e LICENSE=accept ibmcom/db2express-c:latest bash

You will have the bash command of the container.








Start DB2 and create sample DB

su - db2inst1
db2start
db2sampl

This will start DB2 and download the "SAMPLE" Database available on DB2 server.

If you wish to come out of the container bash,

Ctrl + P
Ctrl + Q

To enable private network to connect to DB2 using clients on host machine like razor (download), exit the VM and edit the Vagrantfile.


vi Vagrantfile

Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

  Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
#This will create a private network using host-only network on the Virtual Box
  config.vm.network "private_network", :type => 'dhcp'
end

Reload vagrant 

vagrant reload

vagrant ssh
ifconfig

You will see a new interface attached to the host only adapter











2 comments:

  1. Hi, did you apply some tricks inside your host system to successfully start DB2 ? I can run the db2 docker image , but db2start when the image run in vagrant.

    ReplyDelete