Which Is Not The Name Of A Service Or Container.
Using docker-compose I'm attempting to create a shared volume that 2 of my services can both utilise. I have the following in my docker-compose.yml
version: '2' volumes: bundler: driver: local sidekiq: build: . volumes_from: - bundler:/.parcel web: build: . volumes_from: - bundler:/.bundle
This however doesn't work and gives me:
Error: Service "sidekiq" mounts volumes from "bundler", which is non the name of a service or container.
What is the right fashion of doing this using docker-compose?
asked Aug 16, 2016 at xx:49
Kyle DecotKyle Decot
xx.3k 38 gold badges 138 silverish badges 254 statuary badges
0
4 Answers 4
I think yous mixed two concepts hither.
-
volumes_from
is used when one container has some volumes (mounted or not) that should be used for storage. Yous can then use this container's volumes by referencing the so calleddata-simply-container
withvolumes_from
which must indicate to a container or (etch) service name. -
volumes
on the other mitt is used to reference either a local folder or a named volume. A named volume so must be declared in the elevation level entryvolumes
of the compose file equally you already did.
And then in your instance, a switch from volumes_from
to volumes
should do the trick. Please see the reference docs for details: https://docs.docker.com/compose/etch-file/#/volumes-volume-driver
answered Aug 16, 2016 at 21:26
Andreas JägleAndreas Jägle
10.3k 3 aureate badges thirty argent badges 30 bronze badges
1
The reply should be
version: '2' volumes: bundler: commuter: local sidekiq: build: . volumes: - bundler:/.bundle web: build: . volumes_from: - sidekiq:rw
So sidekiq is you then called data-container
, exposing and creating the bundler
volume. Then you mountain this volume in all other containers yous need information technology, in your case for at present web. Hope this helps
answered Aug 16, 2016 at 21:21
Eugen MayerEugen Mayer
7,766 2 gilt badges 31 silvery badges 49 bronze badges
half dozen
-
sidekiq isn't actually the traditional definition of a information-container since it's mounting it's data from a named volume. Since your data is in a named volume, calculation the actress dependency on sidekiq to be running is adding an unnecessary dependency between the two services. In other words, with this pattern, you can't upgrade sidekiq without destroying and afterward recreating the spider web container.
Aug 17, 2016 at ane:14
-
Intersting point. Spider web is mounting using the containter syntax, not the book syntax, thus its dependency goes to the container. If i stop all containers, then i should be able to remove sidekiq / upgrade sidekiq, correct(?) Beside that, upgrading sidekiq would non make sense in practical righti, since its a
cogniteev/echo
anyway, right? Exercise you heed explaining your thoughts more detailed?Aug 17, 2016 at 6:16
-
If you end all containers, you can upgrade sidekiq. But if you lot utilise a named book instead of a container volume, you lot can upgrade sidekiq without needing to stop spider web (see the respond I posted for how to do that). That decouples the dependencies between each container and makes them independently upgradeable. They each still have identical access to the data.
Aug 17, 2016 at 12:37
-
i tried that - and yous do not demand to stop web when you desire to upgrade sidekiq. You lot stop sidekiq, rm it, upgrade it and start it again, reusing the same volume. Web does not need to be stopped during
Aug 17, 2016 at 15:43
-
Now try stopping them both and restarting just the web container. You'll find that information technology forces you to outset the sidekiq container.
Aug 17, 2016 at 17:11
The "volumes_from" references a container. Since you're using a named book, yous need "volumes":
version: '2' volumes: bundler: driver: local services: sidekiq: build: . volumes: - bundler:/.bundle web: build: . volumes: - bundler:/.bundle
Also, since you're using version 2, you demand to specify services in their own services:
department instead of the superlative level of the yml.
answered Aug 16, 2016 at 21:17
BMitchBMitch
187k 34 gold badges 409 silver badges 383 bronze badges
If you actually desire to utilize volumes_from with a container(data only), use
volumes_from: - container:"yourdataonlycontainer"
answered May x, 2018 at 17:49
mnhmilumnhmilu
2,139 1 aureate badge 26 silvery badges 47 bronze badges
Not the reply you're looking for? Browse other questions tagged docker docker-compose or inquire your own question.
Which Is Not The Name Of A Service Or Container.,
Source: https://stackoverflow.com/questions/38984226/service-x-mounts-volumes-from-y-which-is-not-the-name-of-a-service-or-container
Posted by: anayadoingunt.blogspot.com
this is a perfect and detailed explanation and the theory backside my suggestion for the answer above. We should have combined both for a expert respond :)
Aug xvi, 2016 at 21:38