Monday, June 2, 2025

Export existing distrobox environment to another machine

 

On the Source Machine (Exporting)

see also: https://www.perplexity.ai/search/detailed-instructions-on-how-t-g5vpRZiUSx6L6aE6fk.5og#0

1. List Your Distroboxes

First, identify which distrobox you want to export:

bash
distrobox list

2. Stop the Distrobox

Stop the container you want to export (replace mydevbox with your container name):

bash
distrobox stop mydevbox

3. Export the Container

Use podman to export the container as a tar archive:

bash
podman export mydevbox > mydevbox-export.tar

4. Save the Distrobox Configuration

Export the distrobox configuration to recreate it with the same settings:

bash
distrobox generate-entry mydevbox > mydevbox-config.desktop

Alternatively, note down the original creation command. You can find this information with:

bash
podman inspect mydevbox | grep -A 20 "Labels"

Transferring Files

Transfer both files to your target machine using your preferred method:

Via SCP:

bash
scp mydevbox-export.tar mydevbox-config.desktop user@target-machine:~/

Via USB drive, network share, or cloud storage: Simply copy both files to your transfer medium.

On the Target Machine (Importing)

1. Import the Container Image

Import the tar file as a new container image:

bash
podman import mydevbox-export.tar mydevbox:latest

2. Recreate the Distrobox

Create a new distrobox using the imported image. If you have the original creation command, use that. Otherwise, create it with basic settings:

bash
distrobox create --name mydevbox --image mydevbox:latest

If you need specific options (like additional volumes, environment variables, etc.), add them:

bash
distrobox create --name mydevbox --image mydevbox:latest \
  --additional-packages "package1 package2" \
  --volume /host/path:/container/path \
  --nvidia  # if you need GPU access

3. Enter and Verify

Enter the distrobox to verify everything transferred correctly:

bash
distrobox enter mydevbox

Check that your development tools, configurations, and files are present.

Alternative Method: Using Distrobox Assemble

For a more automated approach, you can create an assemble configuration file:

1. Create a Configuration File

On the source machine, create a YAML file describing your setup:

yaml
# mydevbox-assemble.yml
container_name: mydevbox
image: registry.fedoraproject.org/fedora-toolbox:38
additional_packages:
  - git
  - nodejs
  - python3-pip
  - vim
init_hooks:
  - "pip install --user some-package"
  - "npm install -g some-global-package"

2. Transfer and Apply

Transfer this file to the target machine and run:

bash
distrobox assemble create --file mydevbox-assemble.yml

Important Notes

  • Home Directory Integration: Distrobox automatically mounts your home directory, so personal files and configs in ~/ will be available immediately on the new machine.
  • Host Integration: Applications installed in the distrobox and integrated with the host (using distrobox-export) will need to be re-exported on the new machine.
  • System Dependencies: Ensure both machines have the same version of distrobox and podman for best compatibility.
  • Storage Space: The exported tar file can be quite large depending on your container's contents. Clean up unnecessary files before export if space is a concern.

This method preserves your entire development environment including installed packages, configurations, and any custom setups within the container.

No comments:

Post a Comment

Getting rtcwake working on Bluefin

#!/bin/bash # User systemd setup for auto suspend/wake on Bluefin #Please run these two commands manually: #1. First, create the sudo rule: ...