Lionel Mace
Lionel Mace

Reputation: 61

Can I populate the content of the Volume I created in Bluemix Containers?

I uploaded a Oracle11g DB image in my Bluemix Container registry. I created a volume called oradbdata in IBM Containers using the CLI:

cf ic volume create oradbdata

Now I need to copy some content into this volume before running the container.

Is there anyway to access this volume and populate its content?

Lionel

Upvotes: 1

Views: 350

Answers (2)

Wolfgang Kulhanek
Wolfgang Kulhanek

Reputation: 11

I suggest adding your files into the container during the container build (e.g. into a /src directory). Then use a startup script for your app. In the script you would check if the mounted directory has the file(s) you need. If not then copy things over. Something like this:

#!/bin/bash

# Test if the volume is empty
if [ ! -f /mountpoint/testfile ]; then

    # Copy the contents from the container image into the volume
    cp -R /src/* /mountpoint

fi

# Now start the app here
/usr/bin/myapp

Upvotes: 1

rspoglia
rspoglia

Reputation: 414

When you start the container you can associate the volume to the desired container path; for example: volume oradbdata -> /var/lib/oradata. When the container then starts the /var/lib/oradata is mapped with your volume and, at that point, you can put data on it either at the start-up of the container or accessing the container via ssh.

Upvotes: 2

Related Questions