How hard is it to move Docker containers to another system?

Or another container type if there’s a better one?

My server was originally connected to my TV to run Kodi and play some games while serving files, so it’s running Xubuntu. While it works well for the most part, I want to set it up properly, and be able to move the services to a new system when the time comes.

I was thinking that Docker, or another container system, would probably be best, because as well as hopefully being able to be moved, installing new software shouldn’t affect anything else.

Am I on the right track? Can containers be moved to another system without needing to be set up again?

I’m running the *arr suite two Java Minecraft servers Plex media server Two copies of qBittorent NZBGet Ombi Mylar Codex and probably some others that I’ve forgotten.

While I’m at it, is there a best OS to base everything on? Preferably free. The server is a 4th generation i5 with 32GB RAM, and currently about 10TB of HDD space, with a small SSD for boot, and a Quadro graphics card for transcoding.

Thanks in advance :)

MangoPenguin,
@MangoPenguin@lemmy.blahaj.zone avatar

Extremely easy if you’ve set your projects up using docker compose files.

Just copy the compose file and data volumes over to the new host, run docker compose up -d and you’re all set.

While I’m at it, is there a best OS to base everything on? Preferably free.

Debian, or Proxmox if you want a webUI for containers and VMs.

Tippon,

Brilliant, thank you :)

My data is on separate drives, so I can just disconnect and reconnect them when I upgrade. I’m planning on doing the OS first, then eventually the computer.

I’ll have a look at Proxmox, thanks :)

shasta,

The data that your software interacts with is external to a container but can be mapped to the container file system so that the software can interact with it. For example, your Minecraft server relies on disk files consisting of the world state and server config files (and plugins if you have any). These will still be on your host system, not inside the container. In order to transfer this to another system, you have to take those files from your host and move them to the new host. Then copy your docker config files over too so you can start a new container that points to your files on disk and it should function the same as it did before, but possibly with a different IP address.

An easy way to think of it is that a container can be restarted, like maybe when you restart the PC. When a container is restarted, all the files in the container reset to their initial state. If you go into a container and create files then restart the container, those files will be gone. Any data that needs to be persisted between restarts needs to go on your host filesystem and volume mount it to the container.

Tippon,

Thanks for replying :)

I think I’m starting to understand it a bit better. Your first paragraph explains what I thought a Docker container would be like, except that I wasn’t sure whether the Minecraft server would be part of the container or not. I always thought of containers as like a mini OS that just runs the required software, and connects to data outside of the container. This is why I thought they could be moved, like a virtual machine can be moved.

Would I be right in thinking that as long as the config is saved externally, the container can be rebuilt on any system with that config file? If so, that’s probably exactly what I need.

My data is currently on separate drives to the OS, so my plan is to replace the installed software, e.g. Radarr, with a containerised version so that everything is in containers where possible, then replace the OS with something more suitable. When the computer eventually gets replaced, I want to be able to start up the containers and be ready to go without having to set up all the software again.

shasta,

Yes that’s correct. And containers are not really portable in the way you described. They do have a mini OS in them but the state is not saved when they are “offline”. So you can think of it as more of a template, called an image. You can save the image to a file, and move that to a new pc and load that back into Docker, but that’s usually unnecessary. As long as you have Internet, you just need to know the name of the image and Docker will just download it if it doesn’t already have it. For most popular programs, you’ll find an image for it already created so just follow the instructions on what settings to use for things like volume mounts and environment variables. This configuration of variables can be saved into a Docker Compose file for easy reuse instead of typing really long command line to run your container. This Compose file is all you really need to move to the other PC and it’ll just download your image and run everything as before.

Tippon,

Oh, that’s even easier than I thought then :)

I’ve got a great internet connection, so as long as I save the Compose files, I can rebuild the image forever, barring changes to the program in the container then. Much easier :D

webuge,

Besides containers, you should look in Ansible too, you can automatize the creation of your infrastructure in other servers.

Tippon,

I’ll have a look, thanks :)

mark,

@Tippon That is a big part of the point behind containers, you don't have any long term state inside them. Migration is just a case of copying the configuration over along with the contents of any persistent volumes.

It's worth looking into Podman instead of Docker, the daemon-less architecture makes it more lightweight and secure as it's easier to have rootless containers. Management can also be easer as being a Red Hat project it integrates well into Systemd.

With your existing server on Xubuntu you may as well stick with Ubuntu Server or Debian for the familiarity.

andruid,

Podman also has tooling for deploying containers as systems services or as k8s deploymentments.

Tippon,

I have no idea what that means! (yet :D).

Time for some research :)

mark,

@andruid @Tippon Stay away from k8s for now, that's more for when you have a cluster of multiple physical servers. The systemd services are more useful in a single server environment.

The way that works is that once you have the containers set up, podman can save the configuration of them as unit files so they can be managed the same way as native server software. This makes it easier to have them all start automatically after a reboot, and is a requirement for enabling automatic updates.

Tippon,

Ah, ok. Thanks for the help :)

Tippon,

Brilliant :)

I’ve just been reading some of the other replies, and, yeah, it looks like containers are the way to go. I’ve got my data on separate drives, so that’s easy enough to deal with, it’s just the container side of things that’s been confusing me.

I’ll have a look at Podman, thanks :)

Like you say, I’m probably better off with a Debian fork, especially as I’m using Mint on my laptop, and should be on my PC if I can find alternatives to a few programs :)

burndown,

Docker is helpful, but won’t be perfect since there’s no built-in migration. You’ll have to move any mounted directories like config and data and stuff. Docker is designed to be able spin up and down constantly, so it doesn’t really hold any persistent data in the image itself.

Also, I know you want free, but have you considered unraid? If you really need free you can try truenas or freenas or whatever, but a user friendly linux distro isn’t usually going to be too much overhead. I’d highly recommend unraid as a good option for users who need an easier way to work with all of their containers but don’t want to go as far as setting up a kubernetes cluster or something.

Tippon,

Thanks for replying, sorry about the delay in replying back :)

That’s a shame about Docker. I haven’t used it properly yet, and was under the impression that it works like a virtual machine, so could be moved or cloned to another system.

I’ve just had a look at Unraid, and while it does look good, it’s not right for me for now. My drives are full of media and I can’t afford a spare for now (the media is replaceable if anything goes wrong)

MangoPenguin,
@MangoPenguin@lemmy.blahaj.zone avatar

Docker is very easy to migrate, all you do is copy the data and compose file over.

burndown,

What he said ^. There’s no automation, you just have to make sure you catch everything is all. I may have made it sound more difficult than I intended, sorry about that!

Tippon,

No worries, I managed to misunderstand, and explain myself badly in the same post, so I’m certainly not going to give anyone else grief for it :D

Apart from my home directory, most of my data is on separate drives to the OS, and ideally would be staying like that. If I can just transfer the container and config, I’d be happy :)

burndown,

Best of luck!!

Tippon,

Thank you :)

canis_majoris,
@canis_majoris@lemmy.ca avatar

deleted_by_author

  • Loading...
  • burndown,

    Kubernetes isn’t exactly the same as docker. It’s an orchestration system for containers like Docker

    earmuff,

    That second part kinda tells that you have no idea what Kubernetes, Podman or Docker is.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • selfhost@lemmy.ml
  • DreamBathrooms
  • everett
  • osvaldo12
  • magazineikmin
  • thenastyranch
  • rosin
  • normalnudes
  • Youngstown
  • Durango
  • slotface
  • ngwrru68w68
  • kavyap
  • mdbf
  • InstantRegret
  • JUstTest
  • ethstaker
  • GTA5RPClips
  • tacticalgear
  • Leos
  • anitta
  • modclub
  • khanakhh
  • cubers
  • cisconetworking
  • megavids
  • provamag3
  • tester
  • lostlight
  • All magazines