Create a RAID volume for docker

I had 2 hard drives and wanted to create a RAID volume and format it it with btrfs and use it for docker.

  • Use lsblk comand to identify the disks to use


sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 39.2M 0 part
├─sda2 8:2 0 10.2G 0 part
└─sda3 8:3 0 921.3G 0 part
sdb 8:16 0 465.8G 0 disk
sdd 8:48 0 465.8G 0 disk

sdb and sdd are the disks I want to use for raid.

  • Use fdisk to create “Linux Raid Autodetect” partitions on the disks

fdisk /dev/sdb

#Command: n  - new partition

#Command t - Change fs type to  fd

#Command w - write the partition to disk

Then do the same for /dev/sdd

  • Now, you can see the partitions with  lsblk

sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part

sdd 8:48 0 465.8G 0 disk
└─sdd1 8:49 0 465.8G 0 part

  • create theRAID volume

mdadm --create /dev/md128 --level=0 --raid-disk=2 /dev/sdb1 /dev/sdd1

  • Now you can see the RAID volume with  lsblk

sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part
└─md128 9:128 0 931.3G 0 raid0

sdd 8:48 0 465.8G 0 disk
└─sdd1 8:49 0 465.8G 0 part
└─md128 9:128 0 931.3G 0 raid0

  • Create a file system on the new RAID volume

mkfs.btrfs -f /dev/md128

  • Add a mount point in  /etc/fstab

vi /etc/fstab

#add this line

/dev/md128     /var/lib/docker      btrfs       defaults 1 2

  •  mount the docker folder

mount /var/lib/docker

  • Now you can see the mount point on the RAID volume with lsblk


sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part
└─md128 9:128 0 931.3G 0 raid0 /var/lib/docker

sdd 8:48 0 465.8G 0 disk
└─sdd1 8:49 0 465.8G 0 part
└─md128 9:128 0 931.3G 0 raid0 /var/lib/docker

We’re done, enjoying the big docker RAID volume.






Posted in docker, linux | Leave a comment

Recover a docker container which ran out of space with device mapper

When installing docker on a centos/redhat distribution the default copy-on-write file driver is device mapper and the default size for each container is 10Gb. As soon as the container exceeds this, it will crash, and , when trying to start it, you’ll get something like:

Cannot start container myContainer.
System error: can't create pivot_root dir ,
error mkdir /var/lib/docker/devicemapper/<wbr />mnt/<wbr />4039724368a939e508fefaf7f1242e<wbr />94a6000d30c0b75b45c0e5bdf81925<wbr />296a/rootfs/.pivot_<wbr />root575410080: no space left on device

With recent linux versions (centos 7), I was able to recover the container, by following these steps:

  • Save the container as an image, using docker commit
  • Save the new image as a tar file on disk, using docker save
  • Reconfigure the default space per container, as explained in this post
  • In the previous step will loose all local images and containers, but you have saved your image as a tar file on disk.
  • load the image you previousley saved, using docker load
  • run a new container from the just loaded image, using docker run


Posted in docker, linux | Leave a comment

Install oracle client on Redhat 7

When trying to run one of our application on a Redhat 7 amazon  instance, I had this error: cannot open shared object file: No such file or directory

DBMS API Library loading fails
This library is a part of DBMS client installation, not SQLAPI++
Make sure DBMS client is installed and
this required library is available for dynamic loading

1) The directories in the user's LD_LIBRARY_PATH environment variable
2) The list of libraries cached in /etc/
3) /usr/lib, followed by /lib

The application needed the oracle client library to connect to our Oracle DB.

To install it, we did:

  • download from oracle the file oracle-instantclient12.1-basic-
  • install it:
    • yum install oracle-instantclient12.1-basic-
  • Create a symbolic link

cd /usr/lib/oracle/12.1/client64/lib/

ln -s




Posted in Cracking the coding interview - a python experience | Leave a comment

Start a docker container on CentOS at boot time as a linux service

I have an amazon EC2 instance running RedHat 7, with docker service installed and enabled. I need a particular container to be started at boot time.
I have done this by installing a service which runs after the docker service is executed.

Note: If docker daemon does not start at boot, you might want to enable the docker service

systemctl enable docker.service

Here are the steps.

Create the file /etc/systemd/system/docker_demo_container.service


ExecStart=/usr/bin/docker start my_container_name
ExecStop=/usr/bin/docker stop my_container_name


Now I can start the service

systemctl start docker_demo_container

And I can enable the service so it is executed at boot

systemctl enable docker_demo_container

That’s it, my container is started at boot.

Also take a look at related docker documentation.



Posted in docker, linux | Leave a comment

[Solved] My Java application fails to connect to my Oracle database

Yesterday we debugged with Pepe some random connection reset exceptions in our application when trying to connect to the Oracle database. He wrote this nice post about it.

Goldfish tips


Yesterday we faced a very weird issue: we have a Java application connecting to an Oracle DB via ojdbc6.

In these days it stopped working, magically: no relevant changes in the system configuration or source code.

The application couldn’t connect to the database: on client side, debugging the stack traces shown it was stuck in the logon process; on server side, Oracle was killing the connection for a timeout waiting for the client:


What’s weird is that we could successfully connect to the same DB using the same credentials of our application via SqlPlus, SQL Developer. And even the same application worked fine from another machine using the same JDK.

To make sure it wasn’t our application, we tested with the following small java class (please forgive the style):

This class shown the same problems of our application but it turned out to be very convenient because…

View original post 130 more words

Posted in java, linux | Leave a comment

Install or upgrade to docker 1.8.x on ubuntu 15.04

Ubuntu 15.04 repositories only contain docker 1.5, therefore, this is the version you get if you apt-get install docker on ubuntu.
If you need (and you should) latest version of docker (here 1.8.3), these are the steps you need to perform (as root):

Update the apt-get source

 vi /etc/apt/sources.list
 #Append this line:  
 deb ubuntu-vivid main

Then type this at command prompt

apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

install/upgrade docker

apt-get update
apt-get install docker-engine

Note: If you are upgrading, accept all default options (for configuration override) when prompted.

configure docker
For some reason, the file /etc/default/docker which used to contain the docker options is not read anymore. You can add docker option by editing the file /lib/systemd/system/docker.service and add the options at the end of the line

ExecStart=/usr/bin/docker daemon -H fd://

For instance, mine looks like this

/usr/bin/docker daemon -H fd:// --insecure-registry my.private.domain:5000 -g /docker

Restart the docker service

   systemctl daemon-reload
   service docker stop
   service docker start


Posted in docker | Leave a comment

Clean files on oracle server to free up disk space

I’m an oracle newbie .  Today I had to free up some disk space on our oracle server.

I had to:

  • Step1. delete old databases not used anymore
  • Step2. clean-up the database logs

Step1. delete old databases not used anymore 

  • ssh to the db sever with -X and run dbca
ssh -X oracle@myOracleServer

When dbca window opens, select “Delete Database”, then delete your databases.

Step2. Delete old logs

  • run adrci
  • show homes
adrci> show homes
ADR Homes
  • For each home delete all logs older than one day
adrci>  set homepath diag/tnslsnr/targaryen/listener
adrci> PURGE -age 1440 -type ALERT
Posted in Cracking the coding interview - a python experience | Leave a comment