New to docker and docker-compose, have written compose file that starts couple of services one of which relies on mongo database. I downloaded mongo image a while back and loaded it with data in a container. When I start my mongo instance up via docker-compose starts a new container based on empty image so don't get the data.
Been reading about volumes as a way of trying to get compose to use the data from the existing container and have tried several permutations now and just can't get it to find the data.
When I start the container with the data and do inspect I get :
"Mounts": [
{
"Type": "volume",
"Name": "3f78b88e3e06f31d5f65a45bb1cb964245551875218d065162625cc73e662b1e",
"Source": "/var/lib/docker/volumes/3f78b88e3e06f31d5f65a45bb1cb964245551875218d065162625cc73e662b1e/_data",
"Destination": "/data/configdb",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Type": "volume",
"Name": "d3f89470c9f8c53b55c30338f691eb1586600343004c502feffe8f81091d7d5c",
"Source": "/var/lib/docker/volumes/d3f89470c9f8c53b55c30338f691eb1586600343004c502feffe8f81091d7d5c/_data",
"Destination": "/data/db",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
So am I right in saying I need to somehow get new container to use these mount points using volume tag ?
Have tried:
volumes:
- type: volume
source: /var/lib/docker/volumes/3f78b88e3e06f31d5f65a45bb1cb964245551875218d065162625cc73e662b1e/_data
target: /data/configdb
volume:
nocopy: true
- type: volume
source: /var/lib/docker/volumes/d3f89470c9f8c53b55c30338f691eb1586600343004c502feffe8f81091d7d5c/_data
target: /data/db
volume:
nocopy: true
and :
volumes:
- /data/configdb:/var/lib/docker/volumes/3f78b88e3e06f31d5f65a45bb1cb964245551875218d065162625cc73e662b1e/_data
- /data/db:/var/lib/docker/volumes/d3f89470c9f8c53b55c30338f691eb1586600343004c502feffe8f81091d7d5c/_data
But to be honest grasping at straws, any help in an example of what I should be doing to use the exisiting data would be much appreciated.
Lawrence