hey what's going on so you have a local
folder or directory and you want to put
it inside your docker container well
let's go see how we can do that all
right let's say you have a folder
and it's full a bunch of configuration
files like you have config.json
or you have a dot env file
or you have some kind of
log file and you want to get all that
stuff
inside of your little run your docker
container that you're going to start up
fortunately there's a very simple
command
it's docker
run
dash v for volume and your local folder
or directory
and then colon and where you want the
mount points
inside
the docker container
and then any changes we do inside the
docker container to all that those that
mount point of all those files they will
persist through the life cycle of the
docker container but i should point out
here that if you need to share any of
this
data with any other container
then this is not the right you should
take because they cannot be shared with
any of any other running container all
right over in our working directory we
have a config folder in that config
folder we just have
a
bunch of
files that are going to be used for a
configuration they don't really have
anything of importance so
let's just print out
what's in there
there we go so our config.json is just a
dummy path uh var lib docker or and env
has a greeting of hello and
our gui.log just has some silly
information in there so now we can run
our docker container and attach this
file this
folder or directory to that container
go ahead and reset there
so it's docker run dash v and then we
can use
our directory config
and then we'll mount it inside
root config
and then we'll run this as interactive
and
detached and we'll just use alpine
all right let's see what it is here
let's expand this out because it's all
funny
all right it's this container here
docker exec we're going to go into this
one
go to the shell
and we got our config so let's go over
the config
uh oh there's nothing there oh
all right maybe we did something wrong
with the path
let's go and exit this
and we're gonna go ahead and stop that
container
and
prune our system
now let's go ahead and reset this all
right so let's try this again we're just
going to go up so maybe if we just do
dot slash
oh let's see air response from let's say
you create
config include some valid characters of
a local volume name
uh huh so we must use the absolute path
all right let's try this one more time
so we're going to use
print working directory and then that
config directory
into alpine so this should work this
time
all righty
docker exec
yep
exec
into our container into the shell
and now
we go to our config
we have all our files in there awesome
so let's go into our
gui.log and make an update
so we have another date this time we
have an error
oh something went wrong
then we'll go ahead and exit other
and then we'll go ahead and exit our
container
and then if we go
cat out our config.gui log you'll see
that it updated
inside or outside of the container so
now we have that mounted and bound to
the container but you cannot use this in
any other container so if you want to do
that
you should watch my other video on
docker volumes which will be right here
so thanks for watching and we'll see
[Music]