Mount a Host folder as a volume
I am trying to mount a host folder
/data/atif
inside my workspace using the following settings.
But I am not seeing anything inside my workspace /home/atif/
What I am doing wrong.
The folder already exists on the docker host and have some sub directories and files.33 Replies
Can you
docker inspect
the container that gets created?Seems like others have the same issue with the Docker provider: https://github.com/kreuzwerker/terraform-provider-docker/issues/87
GitHub
docker_container volumes host_path ignored · Issue #87 · kreuzwerke...
This issue was originally opened by @schlitzered as hashicorp/terraform-provider-docker#139. It was migrated here as a result of the community provider takeover from @kreuzwerker. The original body...
I would start by removing
volume_name = docker_volume.home_volume.name
It seems weird for me to reference a docker_volume
when we're trying to mount the local filesystem into the container.so any suggestions?
Did you try removing
volume_name
?^ I would try this
it worked.
I can also now safely delete the
docker_volume
from my template. right?Yep, that should be fine
Posted an update on that issue: https://github.com/kreuzwerker/terraform-provider-docker/issues/87#issuecomment-1225988145
Doing this makes the
/home/coder
volatile and all my installed packages vanish after a workspace restart.
How can I keep packages installed persistent?Doing this makes the /home/coder volatileIt sounds like it's doing an overlay mount and not a bind, which is probably what you want
How can I keep packages installed persistent?If you're using a Docker image, add your packages to the base image
EVerything installed by the user should survive workspace restarts
I added most of them to the docker image is about 13 GB now. But my users want to build or install additional packages
Those should survive restarts
If you run your workspace and then
docker inspect
the container that it creates, you should see a big JSON object -- can you copy that, redact any information you don't want others to see, and then paste it here?you should make a volume at the apt folder then
otherwise your packages will always disappear
some of the packages are installed by pip or conda
and some are built from source
then change pip packages' dir or mount a volume at their path
there's not much else you can do sadly
This is my current main.tf
I am already mounting a host folder inside the workspace as /home/user/data
yeah
that will only make /home/user/data persist
nothing else
yes
So how to keep everything persist?
I mean to survive workspace restarts
so you should look at where APT pkgs are installed and where pip/conda
you don't
you could but it would take way too much space
I'm not even sure you could
but yeah, just find the locations you want to persist and assign volumes to them
ahan
How can I add another volume? without affecting the existing one?
hmm
I don't know
maybe add another
volumes {}
entry
that might overwrite the other one but idn
idk
try it outtrying
Lets see
I wouldn't do that
This worked ❤️
great to know for the future !
so now you'd just have to locate where the folders you need are
I would use actual volumes rather than host overlay mounts btw
if you need to access the volumes' content it's available at
/var/lib/docker/volumes
what is the difference? and actual volumes are your preference?
yes they are, because docker creates them automatically for you
how would I do that?
What should I change to achieve that?
so here, the volume for
/home/coder
will be associated to the coder-<username>-<workspacename>-root
docker volumeThanks
fr the 2nd mount I am using a volume I guess
I would use volumes for everything but you do you
marking as resolved