Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup and transfer to other host #99

Open
SimonBard opened this issue Oct 16, 2024 · 3 comments
Open

Backup and transfer to other host #99

SimonBard opened this issue Oct 16, 2024 · 3 comments

Comments

@SimonBard
Copy link

Operating system

22.04

Description

What is the best way to backup a docker container and transfer to new host?

I see this possibilities:
- docker way

  1. docker commit NAME_OF_INSTANCE mycontainerimage
  2. docker save -o mycontainerimage.tar mycontainerimage
  3. docker load -i ./mycontainerimage.tar
  4. docker create --name my-nginx-container -p 8080:80 mycontainerimage
  5. docker start my-nginx-container

Apple way:

  • Somehow backup the apple system with system tools (I dont know yet) and restore when running a new docker container

Docker compose

not relevant

Docker log

not relevant

Screenshots (optional)

No response

@kroese
Copy link
Contributor

kroese commented Oct 16, 2024

Committing to the image will not work. But its written in the readme how to do it:

volumes:
  - /var/osx:/storage

And then just backup the example /var/osx folder and transfer it to the new PC.

@SimonBard
Copy link
Author

Thanks, I cannot get it running though. I copied the content of the volume created by docker to Downloads and tried to start a container:

This is how the directory looks like:

$ ls -lh /home/simon/Downloads/macos-backup/_data
insgesamt 24G
-rw-r--r-- 1 root root 638M Okt 13 21:05 base.dmg
-rw-r--r-- 1 root root 256M Okt 13 21:05 boot.img
-rw-r--r-- 1 root root    9 Okt 13 21:05 boot.version
-rw-r--r-- 1 root root  64G Okt 17 08:40 data.img
-rw-r--r-- 1 root root   18 Okt 13 21:05 macos.mac
-rw-r--r-- 1 root root 1,9M Okt 13 21:05 macos.rom
-rw-r--r-- 1 root root 128K Okt 16 13:56 macos.vars
-rw-r--r-- 1 root root    8 Okt 13 21:05 macos.version

Startup & error:

~/Downloads/macos$ docker-compose up -d
WARNING: Found orphan containers (4553fbfe403c_macos) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Recreating macos ...

ERROR: for macos  'ContainerConfig'

ERROR: for macos2  'ContainerConfig'
Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 33, in <module>
    sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
    command_func()
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 203, in perform_command
    handler(command, command_options)
  File "/usr/lib/python3/dist-packages/compose/metrics/decorator.py", line 18, in wrapper
    result = fn(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 1186, in up
    to_attach = up(False)
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 1166, in up
    return self.project.up(
  File "/usr/lib/python3/dist-packages/compose/project.py", line 697, in up
    results, errors = parallel.parallel_execute(
  File "/usr/lib/python3/dist-packages/compose/parallel.py", line 108, in parallel_execute
    raise error_to_reraise
  File "/usr/lib/python3/dist-packages/compose/parallel.py", line 206, in producer
    result = func(obj)
  File "/usr/lib/python3/dist-packages/compose/project.py", line 679, in do
    return service.execute_convergence_plan(
  File "/usr/lib/python3/dist-packages/compose/service.py", line 579, in execute_convergence_plan
    return self._execute_convergence_recreate(
  File "/usr/lib/python3/dist-packages/compose/service.py", line 499, in _execute_convergence_recreate
    containers, errors = parallel_execute(
  File "/usr/lib/python3/dist-packages/compose/parallel.py", line 108, in parallel_execute
    raise error_to_reraise
  File "/usr/lib/python3/dist-packages/compose/parallel.py", line 206, in producer
    result = func(obj)
  File "/usr/lib/python3/dist-packages/compose/service.py", line 494, in recreate
    return self.recreate_container(
  File "/usr/lib/python3/dist-packages/compose/service.py", line 612, in recreate_container
    new_container = self.create_container(
  File "/usr/lib/python3/dist-packages/compose/service.py", line 330, in create_container
    container_options = self._get_container_create_options(
  File "/usr/lib/python3/dist-packages/compose/service.py", line 921, in _get_container_create_options
    container_options, override_options = self._build_container_volume_options(
  File "/usr/lib/python3/dist-packages/compose/service.py", line 960, in _build_container_volume_options
    binds, affinity = merge_volume_bindings(
  File "/usr/lib/python3/dist-packages/compose/service.py", line 1548, in merge_volume_bindings
    old_volumes, old_mounts = get_container_data_volumes(
  File "/usr/lib/python3/dist-packages/compose/service.py", line 1579, in get_container_data_volumes
    container.image_config['ContainerConfig'].get('Volumes') or {}
KeyError: 'ContainerConfig'

This is the docker compose:

services:
  macos:
    image: dockurr/macos
    container_name: macos
    environment:
      VERSION: "big-sur"
    devices:
      - /dev/kvm
    cap_add:
      - NET_ADMIN
    ports:
      - 8006:8006
      - 5900:5900/tcp
      - 5900:5900/udp
    stop_grace_period: 2m
    volumes:
      - /var/osx/_data:/storage

@kroese
Copy link
Contributor

kroese commented Oct 17, 2024

When I google for that error, all the posts say to use docker compose up instead of docker-compose up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants