Docker Community Forums

Share and learn in the Docker community.

Restore tar from another host to fresh Docker Desktop

I am attempting to migrate a docker container from a raspberry pi to a windows machine running docker desktop.

I’ve created a tarball, which should include the container and the volume data using this command:
docker run --rm --volumes-from mynodered -v $(pwd):/backup busybox tar cvfz /backup/backup.tar /mynodered/

I’ve moved that tarball over to my windows machine with SCP and left it on the Desktop for now.

I’ve created an empty “mynodered” container on the windows machine (otherwise I get an error that the container doesn’t exist).

Now I’m trying to update the “mynodered” container using the tarball on the windows machine with a command like this, but please help me fill in the CONTAINERPATH and recommend how I should replace $(pwd).
docker run --rm --volumes-from mynodered -v $(pwd):/backup busybox bash -c "cd CONTAINERPATH && tar xvf /backup/backup.tar --strip 1"

Do I need to move the tarball to a specific location in windows directory?

Please let me know what other info may be helpful. Thanks!

Why do you want to export the container’s filesystem? You should’t do that. And if you want, you can use docker container export.

If you save everything to a volume, then you can create a new container from the same image. If you created the original image without Dockerfile or you don’t have that Dockerfile, you can use docker image save to “export” the image and “import” it using docker image load

How did you do that? Did you build an image from “scratch”?

Thanks for the reply! I’m happy to hear any suggestions you have on the best way to achieve my goal of migrating node-red from a raspberry pi to a windows host.

I want to export node-red in a way that brings along all of the packages I’ve installed and flows I’ve created within, so I thought bringing the file-system was the best way to do that. It would be somewhat difficult to re-create all the work I’ve put into node-red in a fresh instance.

From your advice, it sounds like I should use the docker image save method, since I don’t recall how I created the instance in the first place.

I created the empty “mynodered” container with a simple docker run command; nothing fancy. Maybe that step isn’t necessary.

I don’t want to be the person who focuses only on what you did wrong in the past instead of helping, but do you know that you should not install anything inside a container interactively unless you want a quick test and delete the container? The proper way is to try it in a container and create a Dockerfile with the instructions so you can build your image and run the container from it?

docker image save can save an image but you mentioned that you don’t have an image to save since you installed everyhing in a running container instance. You can still use this command but you have to create an image from that container. Use docker container commit before docker image save

docker container commit "your_container_name" "your_image_name"
docker image save "your_image_name" --output "your_image_name.tar"

Copy it to the other machine and use docker image load to import it:

docker image load --input your_image_name.tar

I does not seem to be a good idea. You I am not mistaken you wanted to copy the exported filesystem into a container which was based on an image having its own read-only filesystem. This way you would replace every file on the read-only filesystem which means which is also on the container filesystem.

I don’t think using the container’s filesystem is the best way but if the other way does not work or if you just want to try an alternative solution just for fun, I think you could create a Dockerfile with this content:

FROM scratch
COPY folder_of_the_container_filesystem/ /

However you would lose all of the metadata defined in the original image like environment variables, workdir and commands.

Thanks again for the advice. I don’t mind you mentioning what I did wrong because I would like to learn the best or proper way of doing things.

In this case, I’m not sure the proper way to use node-red in a way that can be moved between hosts if I want to upgrade my server in the future. The basic use of node-red is to interactively create programming flows within it to perform functions, so it’s not useful if I shouldn’t update it interactively.

However, I appreciate your suggestions on how to achieve my goal from my current situation. I’ll try the “commit”, “image save” and “image load” commands and report back.

I’ll also delete the empty docker container that I created since it seems to have no value.

I hope that I’m understanding everything correctly here. I’m learning quickly as I can.

Thank you for the explanation. I didn’t know node-red.