Hello!
I need a guide on how to migrate data from shared hosting to Docker.
All the guides I can find are about migrating docker containers though!
I am going to use a PaaS - Caprover which sets up everything.
Can I just import my data into the regular filesystem or does the containerisation have sandboxed filesystems?
Thanks!
Just move your data and then either create bind mounts to those directories or create a new volume in docker and copy the data to the volume path in your filesystem.
I also suggest looking into podman instead of docker. Its basically a drop in replacement for docker.
Yes, I would set up the containers empty, then import your data however the applications want it. Either by importing via their web interface, or by dropping it in their bound directory.
Thanks! I will have to research volumes!
Bind mount - that would mean messing with fstab, yes?
I set up a bind for my desktop but entering mounts in fstab has borked me more than once!
I'll try to answer the specific question here about importing data and sandboxing. You wouldn't have to sandbox, but it's a good idea. If we think of a Docker container as an "encapsulated version of the host", then let's say you have:
Service A running on your cloud
Requires apt-get install -y this that and the other to run
Uses data in /data/my-stuff
Service B running on your cloud
Requires apt-get install -y other stuff to run
Uses data in /data/my-other-stuff
In the cloud, the Service A data can be accessed by Service B, increasing the attack vector of a leak. In Docker, you could move all your data from the cloud to your server:
# On cloud
cd /
tar cvfz data.tgz data
# On local server
mkdir /local/server/
cd /local/server
tar xvfz /tmp/data.tgz ./
# Now you have /local/server/data as a copy
You're Dockerfile for Service A would be something like:
FROM ubuntu
RUN apt-get install -y this that and the other
RUN whatever to install Service A
CMD whatever to run
You're Dockerfile for Service B would be something like:
FROM ubuntu
RUN apt-get install -y other stuff
RUN whatever to install Service B
CMD whatever to run
This makes two unique "systems". Now, in your docker-compose.yml, you could have:
This would make everything look just like the cloud since /local/server/data would be bind mounted to /data in both containers (services). The proper way would be to isolate:
You can copy files into the docker image via a COPY in the dockerfile or you can mount a volume to share data from the host file system into the docker container at runtime.