- [Instructor] When you deploy your applications
through Docker's forum using services
or if you have those services deployed through stack files,
at some point you're going to want to modify
the volume mounts.
To do this, you could use the Docker service update
command.
If we scroll down here, you'll find
in alphabetical order under M.
Here we have --mount-add to add or update a mount
on an existing service.
If you scroll down even further,
there are command examples on exactly how to do it,
add or remove mounts on an existing service.
So it shows you how to deploy a service with a mount,
or if you have an existing service,
how to modify that service to add the mount,
and that's exactly what we'll be doing in this video.
Now, alternatively, if you deployed the service
through a stack file, there is documentation
in the yaml reference for the stack files,
and again, if you go down in alphabetical order,
it's actually under V for volumes towards the end.
And this is where it tells you how to add
a volume to a stack file.
So you would update the stack file
and include the volume reference under each
of the different services as part of that stack.
In our case, we have a number of different running services.
I'll do a docker service ls,
and you can see, we have the web app,
and we have my stack web.
My stack web is part of the my stack stack,
and in this case, we're just going to modify
the my stack web service.
So if we do a Docker service ps my stack web,
you can see there's roughly 30 replicas running out here
on the Docker cluster.
We're going to clear the screen,
and the command we want to do is Docker service update
- -moun-add, and then we'll enter
the type of the volume here.
In this case, it's just going to be volume comma source
equals, and in this case, it's going to be web dash
volume, this is a new volume we're actually creating.
And the target is going to be web dash,
and then the name of the service.
In our case, it's mystack_web.
And there we go.
We modified the stack.
We can actually do a Docker service inspect
on my stack web and grep for volume, or vol,
and there you go.
You can see a new volume was added.
The type is volume, source web vol,
target web vol dir.
If we do a Docker volumes ls,
we actually find out that that's not a command,
because it's Docker volume ls.
There we go.
So there's the web vol that was created
when we added the web vol volume to the running service.
So that's how you use Docker service update
to update a service to add a volume,
or alternatively you can go and you can edit
your stack file if you deploy that service
through a stack and then update the stack itself.