Migrating Docker running container to a new vm

Hello all,
Hope you all are doing well Need one help
Need to migrate the containers-based application from one vm to another due to decommissioning of existing vm with the data as well which include postgres container as well

Hi,

Based on the limited details you provided, here’s my suggestion:

Before migrating your containers, check if the data is mounted.

  • If it’s not mounted, back it up:
    • Use pg_dump for the PostgreSQL database.
    • Use docker cp to copy data from the application container.
  • If it’s mounted, simply transfer it using scp.

After transferring, start the containers on the new server with the same image tags and make sure the data is mounted correctly. Finally, test the application before shutting down the old server.

@raymond.baoly thanks for your suggestion one question can I use docker commit to create to create the image of running app container whereas for postgres db we have volume created so if move the content of /var/lib/docker to the new vm and also the image created using commit and start the containers would that be fine?

Hi Suraj7,

I think your approval is possible, but I haven’t worked with it yet. Personally, I prefer to mount and back up the storage files. It feels easier for me.