如何正确安装 Docker 和 VirtualBox?

如何正确安装 Docker 和 VirtualBox?

在尝试测试使用此 cookiecutter 模板完成的代码时,我遇到了不少问题:https://github.com/Dekalabs/cookiecutter-backend

它一直冻结,所以我认为问题与docker有关。

我运行时出现以下错误$ docker-compose -f local.yml up -d

$ docker-compose -f local.yml up -d
Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 11, in <module>
    load_entry_point('docker-compose==1.25.0', 'console_scripts', 'docker-compose')()
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 72, in main
    command()
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 125, in perform_command
    project = project_from_options('.', options)
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 53, in project_from_options
    return get_project(
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 145, in get_project
    client = get_client(
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 116, in get_client
    client = docker_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 127, in docker_client
    client = APIClient(**kwargs)
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 132, in __init__
    base_url = utils.parse_host(
  File "/usr/lib/python3/dist-packages/docker/utils/utils.py", line 286, in parse_host
    raise errors.DockerException(
docker.errors.DockerException: Invalid bind address format: port is required: 127.0.0.1

我已经尝试了这里建议的所有解决方案(https://askubuntu.com/questions/1064674/linux-headers-reinstall)。我曾多次尝试卸载并重新安装 vbox、运行 dkms 命令等。

请帮忙,请记住我是一个初学者......在这里感觉完全迷失了!

谢谢你!

我尝试过的更多命令和错误消息:

$ docker-machine create default

Running pre-create checks...
Wrapper Docker Machine process exiting due to closed plugin server (unexpected EOF)
Error with pre-create check: "We support Virtualbox starting with version 5. Your VirtualBox install is \"WARNING: The character device /dev/vboxdrv does not exist.\\n\\t Please install the virtualbox-dkms package and the appropriate\\n\\t headers, most likely linux-headers-Microsoft.\\n\\n\\t You will not be able to start VMs until this problem is fixed.\\n6.1.10_Ubuntur138449\". Please upgrade at https://www.virtualbox.org"

$ uname -r

4.4.0-19041-Microsoft
$ sudo apt install --reinstall linux-headers-Microsoft

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-Microsoft

(我尝试过install --reinstall几种不同的结局,但总是出现相同的错误。)

$ software-properties-gtk

Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
WARNING:root:system-image-cli failed, using defaults: [Errno 13] Permission denied: 'system-image-cli'
WARNING:root:system-image-cli failed, using defaults: [Errno 13] Permission denied: 'system-image-cli'

(software-properties-gtk:21982): Gtk-CRITICAL **: 17:47:54.409: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed

(software-properties-gtk:21982): Gtk-CRITICAL **: 17:47:54.412: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed

(software-properties-gtk:21982): Gtk-CRITICAL **: 17:47:54.415: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Segmentation fault (core dumped)
$ apt-cache policy linux-generic

linux-generic:
  Installed: (none)
  Candidate: 5.4.0.48.51
  Version table:
     5.4.0.48.51 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
     5.4.0.26.32 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
$ sudo apt install linux-headers-generic

Reading package lists... Done
Building dependency tree
Reading state information... Done
linux-headers-generic is already the newest version (5.4.0.48.51).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt-get install build-essential linux-headers-`uname -r` dkms virtualbox-dkms

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.4.0-19041-Microsoft
E: Couldn't find any package by glob 'linux-headers-4.4.0-19041-Microsoft'
E: Couldn't find any package by regex 'linux-headers-4.4.0-19041-Microsoft'

答案1

好的,我找到了解决方案——重新安装了 Docker,但似乎我跳过了几个步骤……

相关内容