Karthik
Karthik

Reputation: 315

Data Container In Docker : Data Not Populated

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.

Upvotes: 0

Views: 342

Answers (1)

Chris McKinnel
Chris McKinnel

Reputation: 15102

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

Upvotes: 2

Related Questions