0

Here is my question.

I need to read data from a volume inside my container. Instead of using a ADD command in my docker file to copy this data directly inside my container I need to look for this data from a data placeholder, i.e a container that holds data.

So, I created this data container,

docker run -d -v /var/lib/ABC --name ABC_datastore busybox true.

To my understanding this should create a container ABC_datastore that will contain the data inside the directory /var/lib/ABC of the host from which I am running this command? Am I wrong?

So if my understanding is correct, I can use this container in my main container, docker run -i -t --volumes-from ABC_datastore --name="ABC_ins" -d ABC_img

This should populate the /var/lib/ABC inside my ABC-ins with the right value. But it is not happening. The folder /var/lib/ABC inside my ABC-ins is empty.

I also tried to populate the data using, docker run -d -v /var/lib/ABC --name ABC_datastore busybox true; tar -c /var/lib/ABC | docker run -a stdin -i --volumes-from ABC_datastore busybox tar -xC /var/lib/ABC No luck here too.

Any help will be appreciated. My final goal is to create a data container that will contain the actual data in /var/lib/ABC that can be used inside my container in that given path.

Karthik
  • 315
  • 1
  • 4
  • 17
  • Your final goal is the "data volume container" feature described in the documentation: https://docs.docker.com/userguide/dockervolumes/ – Mark O'Connor Jul 31 '14 at 23:33
  • Yes. But my question is the container doesn't contain the data. I tried both absolute and relative path yet no luck. Is there any way to go into the data container. Tried nsenter/docker-enker. Not possible. – Karthik Aug 01 '14 at 02:30

1 Answers1

2

docker run -d -v /var/lib/ABC --name ABC_datastore busybox true.

To my understanding this should create a container ABC_datastore that will contain the data inside the directory /var/lib/ABC of the host from which I am running this command? Am I wrong?

You need to tell docker where you want to mount your volume inside the container using the format -v /path/to/source:/path/to/destination.

Try:

docker run -d -v /var/lib/ABC:/var/lib/ABC --name ABC_datastore busybox true
Community
  • 1
  • 1
Chris McKinnel
  • 14,694
  • 6
  • 64
  • 67