hercules-ci / arion

Run docker-compose with help from Nix/NixOS
Apache License 2.0
667 stars 48 forks source link

`arion up` fails with example from documentation #159

Closed aanderse closed 2 years ago

aanderse commented 2 years ago

Hi @roberth :wave:

I have been having some fun with arion on fedora 36 lately. Then I hopped on an ubuntu 20.04 box and my fun was abruptly ended :disappointed: I was hoping you could help me out :sunglasses:

I have a very simple setup where I acquire arion via flakes and then hop into a shell via nix flakes develop:

~/arion$ cat flake.nix 
{
  inputs.arion.url = "github:hercules-ci/arion";
  outputs = { self, nixpkgs, arion }: {
    devShell.x86_64-linux = 
      let
        pkgs = nixpkgs.legacyPackages.x86_64-linux;
      in
        pkgs.mkShell {
          name = "arionEnv";
          buildInputs = [ arion.defaultPackage.x86_64-linux ];
        };
  };
}

From there I read the documentation and copy the NixOS: run full OS example into my ~/arion directory. Running arion up doesn't work. I consider that documentation may have diverged from latest master, which I'm using, so I grab the example which corresponds to the git commit of arion that I'm using: https://github.com/hercules-ci/arion/blob/e73710caf92dbc9c9f8f6f4e153adbc377a84138/examples/full-nixos/arion-compose.nix. And still no luck:

~/arion$ arion up
trace: warning: system.stateVersion is not set, defaulting to 22.05. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion.
/nix/store/178g5ywvmpk3w6mx2i7nyns3j8qf3a32-docker-compose.yaml
Recreating df4371a1ed48_arion_webserver_1 ... 

ERROR: for df4371a1ed48_arion_webserver_1  'NoneType' object has no attribute 'get'

ERROR: for webserver  'NoneType' object has no attribute 'get'
Traceback (most recent call last):
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/bin/.docker-compose-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/cli/main.py", line 67, in main
    command()
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/cli/main.py", line 126, in perform_command
    handler(command, command_options)
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/cli/main.py", line 1070, in up
    to_attach = up(False)
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/cli/main.py", line 1051, in up
    return self.project.up(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/project.py", line 643, in up
    results, errors = parallel.parallel_execute(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/parallel.py", line 108, in parallel_execute
    raise error_to_reraise
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/parallel.py", line 206, in producer
    result = func(obj)
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/project.py", line 625, in do
    return service.execute_convergence_plan(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 577, in execute_convergence_plan
    return self._execute_convergence_recreate(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 497, in _execute_convergence_recreate
    containers, errors = parallel_execute(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/parallel.py", line 108, in parallel_execute
    raise error_to_reraise
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/parallel.py", line 206, in producer
    result = func(obj)
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 492, in recreate
    return self.recreate_container(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 610, in recreate_container
    new_container = self.create_container(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 328, in create_container
    container_options = self._get_container_create_options(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 916, in _get_container_create_options
    container_options, override_options = self._build_container_volume_options(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 955, in _build_container_volume_options
    binds, affinity = merge_volume_bindings(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 1531, in merge_volume_bindings
    old_volumes, old_mounts = get_container_data_volumes(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 1562, in get_container_data_volumes
    container.image_config['ContainerConfig'].get('Volumes') or {}
AttributeError: 'NoneType' object has no attribute 'get'

I'm not a docker nerd :nerd_face: so maybe there is something really obvious I'm missing... but basic podman commands like this ~/arion$ podman run --network=host nginxinc/nginx-unprivileged seem to work fine for me.

Any and all help appreciated :bowing_man:.

Additional details:

~/arion$ grep VERSION= /etc/os-release 
VERSION="20.04.3 LTS (Focal Fossa)"

~/arion$ podman --version
podman version 3.2.3

~/arion$ echo $DOCKER_HOST 
unix:/run/user/30065/podman/podman.sock

~/arion$ jq .nodes.arion.locked.rev flake.lock 
"bd3e2fe4e372d0b5f965f25f27c5eb7c1a618c4a"

~/arion$ ls -l $(which docker)
lrwxrwxrwx 1 aanderse aanderse 15 Jun  3 14:36 /home/aanderse/bin/docker -> /usr/bin/podman
roberth commented 2 years ago
File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 1531, in merge_volume_bindings
    old_volumes, old_mounts = get_container_data_volumes(
  File "/nix/store/xyvzv4diazdgm1gsaaca4bj9jamk8h4g-docker-compose-1.27.4/lib/python3.8/site-packages/compose/service.py", line 1562, in get_container_data_volumes
    container.image_config['ContainerConfig'].get('Volumes') or {}

These lines suggest that docker-compose is getting a response from your docker daemon (podman, judging from your additional details) in a schema that's missing at least the ContainerConfig field. So this is a compatibility problem between the bundled docker-compose and your podman version.

Do you think you can try with a newer podman? Podman doesn't need a system service, so it seems quite feasible.

aanderse commented 2 years ago

Do you think you can try with a newer podman?

I have tried with a newer podman on fedora 36 and ubuntu 22.04 and everything was fine. Only issues with ubuntu 20.04 which has an older podman provided by an apt repo ... https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/

I'll see if I can find a newer podman for this version of ubuntu. Thank you @roberth, much appreciated :bow:

aanderse commented 2 years ago

It was the version as you suggested. Thanks @roberth :rocket: