jesseduffield / lazydocker

The lazier way to manage everything docker
MIT License
35.51k stars 1.15k forks source link

Update version execution error: could not determine host context "default" does not exist #493

Open xyabc120 opened 9 months ago

xyabc120 commented 9 months ago

Describe the bug After upgrading from v0.21.0 to v0.23.1, executing the lazydocker command resulted in an error : could not determine host context "default" does not exist unable to parse docker host ''

To Reproduce

  1. choco upgrade -y lazydocker (The first installation was done through 'choco install lazydocker')
  2. lazydocker --version

image

Desktop (please complete the following information):

mark2185 commented 9 months ago

Duplicate of https://github.com/jesseduffield/lazydocker/issues/488.

xyabc120 commented 9 months ago

The ~/.docker folder already exists in my directory, and this issue still exists. I resolved this issue by removing the currentContext attribute from the ~/.docker/config.json file

# set the property value to an empty string
"currentContext": ""
# or remove entire attribute
- "currentContext": "default"
alexravenna commented 9 months ago

The ~/.docker folder already exists in my directory, and this issue still exists. I resolved this issue by removing the currentContext attribute from the ~/.docker/config.json file

# set the property value to an empty string
"currentContext": ""
# or remove entire attribute
- "currentContext": "default"

This solved the issue for me too! Although it never feels good to delete something without even knowing what it does 😅 .

riley-van-hengstum commented 9 months ago

I can remove the currentContext and lazydocker starts working again, but I have to do that every time Docker Desktop restarts.

mark2185 commented 9 months ago

What if you set it to an empty string?

riley-van-hengstum commented 9 months ago

What if you set it to an empty string?

Also when I set it to an empty string. Docker Desktop resets the currentContext back to the default value when it starts.

I seem to have two Docker contexts:

image

I don't know exactly what these do. I tried removing the desktop-linux context, but that also gets recreated when Docker Deskop restarts.

This is on Windows 11, Docker Desktop 4.25.0 and lazydocker 0.23.1

dwvwdv commented 8 months ago

I've encountered the same issue, and @xyabc120's method helps me for now. Is this the only way to go?

guss77 commented 5 months ago

I have the same issue - with ~/.docker/config.json having the line "currentContext": "default", lazydocker will not start.

Setting currentContext to the empty string works around the issue - but then docker-compose won't start:

$ lazydocker --version
Version: 0.23.1
Date: 2023-10-13T07:40:28Z
BuildSource: binaryRelease
Commit: 1060e17731c80372335446eabe6a56ba4facd2b3
OS: linux
Arch: amd64
$ lsb_release --codename
Codename:       jammy
$ docker-compose --version
docker-compose version 1.29.2, build unknown
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 80, in main
    command_func = dispatch()
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 159, in dispatch
    options, handler, command_options = dispatcher.parse(sys.argv[1:])
  File "/usr/lib/python3/dist-packages/compose/cli/docopt_command.py", line 28, in parse
    command_help, options, command = DocoptDispatcher.get_command_and_options(
  File "/usr/lib/python3/dist-packages/compose/cli/docopt_command.py", line 23, in get_command_and_options
    opt = docopt_full_help(command_help, argv, **options)
  File "/usr/lib/python3/dist-packages/compose/cli/docopt_command.py", line 9, in docopt_full_help
    return docopt(docstring, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/docopt.py", line 575, in docopt
    extras(help, version, argv, doc)
  File "/usr/lib/python3/dist-packages/docopt.py", line 485, in extras
    sys.exit()
SystemExit

During handling of the above exception, another exception occurred:

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 129, in main
    exit_with_metrics(command, log_msg=msg, status=status,
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 147, in exit_with_metrics
    MetricsCommand(command, status=status).send_metrics()
  File "/usr/lib/python3/dist-packages/compose/metrics/client.py", line 40, in __init__
    self.context = context_type or ContextAPI.get_current_context().context_type or 'moby'
AttributeError: 'NoneType' object has no attribute 'context_type'
$ docker-compose -p mtproject ps
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 200, in perform_command
    project = project_from_options('.', options)
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
    return get_project(
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
    client = get_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
    client = docker_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 143, in docker_client
    if not context.is_docker_host():
AttributeError: 'NoneType' object has no attribute 'is_docker_host'

Removing the currentContext completely makes both lazydocker and docker-compose work.

Interestingly, with currentContext set to the empty string, lazydocker works but does not show all docker-compose containers, and for some docker-compose containers it shows the wrong name.

c3cris commented 4 months ago

Same issue. Resolved by editing docker config, but that should not be the solution

RollsChris commented 4 months ago

same issue for me :( removing currentContext mkaes lazydocker work but then it gets its added back when restarting docker desktop.. making it unusable

RollsChris commented 4 months ago

weirdly if i use "docker context use default" it disappears from the config file and lazydocker works... but still restarting docker adds it back. Something has got twisted here maybe on the docker side.

Also it might be worth noting switching to desktop-linux context also works

hiro345g commented 4 months ago

As a temporary workaround, I was able to get it to work by specifying the DOCKER_HOST environment variable as DOCKER_HOST="unix:///var/run/docker.sock" lazydocker. (Ubuntu 22.04)

fmanso commented 1 month ago

Any update on this ? How would be the workaround for Windows with Docker Desktop ?

peauc commented 1 month ago

@fmanso would you be able to provide a ~/.docker/config.json that is problematic? I can look onto this issue

peauc commented 1 month ago

I have managed to reproduce this issue on Linux, fix it & draft a PR