Skip to content

Commit f5240e4

Browse files
docs: address issue #23308 (#24115)
## Summary Added documentation for DOCKER_HOST requirement when using Docker SDKs with Docker Desktop for Linux. ## Changes - Added "Using Docker SDKs with Docker Desktop" section to Linux install docs explaining why SDKs need DOCKER_HOST set and providing configuration commands - Added FAQ entry "How do I use Docker SDKs with Docker Desktop for Linux?" with troubleshooting steps - Added note in SDK reference docs alerting Docker Desktop for Linux users to set DOCKER_HOST before using SDKs Fixes #23308 --- 🤖 Generated with [cagent](https://github.com/docker/cagent) --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: aevesdocker <allie.sadler@docker.com>
1 parent 44f42e4 commit f5240e4

4 files changed

Lines changed: 85 additions & 42 deletions

File tree

content/manuals/desktop/setup/install/linux/_index.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
2-
description: Install Docker on Linux with ease using our step-by-step installation
2+
description:
3+
Install Docker on Linux with ease using our step-by-step installation
34
guide covering system requirements, supported platforms, and where to go next.
4-
keywords: linux, docker linux install, docker linux, linux docker installation, docker
5+
keywords:
6+
linux, docker linux install, docker linux, linux docker installation, docker
57
for linux, docker desktop for linux, installing docker on linux, docker download
68
linux, how to install docker on linux, linux vs docker engine, switch docker contexts
79
title: Install Docker Desktop on Linux
810
linkTitle: Linux
911
weight: 60
1012
aliases:
11-
- /desktop/linux/install/
12-
- /desktop/install/linux-install/
13-
- /desktop/install/linux/
13+
- /desktop/linux/install/
14+
- /desktop/install/linux-install/
15+
- /desktop/install/linux/
1416
---
1517

1618
> **Docker Desktop terms**
@@ -23,9 +25,9 @@ This page contains information about general system requirements, supported plat
2325

2426
> [!IMPORTANT]
2527
>
26-
>Docker Desktop on Linux runs a Virtual Machine (VM) which creates and uses a custom docker context, `desktop-linux`, on startup.
28+
> Docker Desktop on Linux runs a Virtual Machine (VM) which creates and uses a custom docker context, `desktop-linux`, on startup.
2729
>
28-
>This means images and containers deployed on the Linux Docker Engine (before installation) are not available in Docker Desktop for Linux.
30+
> This means images and containers deployed on the Linux Docker Engine (before installation) are not available in Docker Desktop for Linux.
2931
>
3032
> {{< accordion title=" Docker Desktop vs Docker Engine: What's the difference?" >}}
3133
@@ -35,7 +37,7 @@ This page contains information about general system requirements, supported plat
3537
3638
Docker Desktop for Linux provides a user-friendly graphical interface that simplifies the management of containers and services. It includes Docker Engine as this is the core technology that powers Docker containers. Docker Desktop for Linux also comes with additional features like Docker Scout and Docker Extensions.
3739

38-
#### Installing Docker Desktop and Docker Engine
40+
### Installing Docker Desktop and Docker Engine
3941

4042
Docker Desktop for Linux and Docker Engine can be installed side-by-side on the
4143
same machine. Docker Desktop for Linux stores containers and images in an isolated
@@ -88,7 +90,7 @@ machine. The current context is indicated with an asterisk (`*`).
8890
$ docker context ls
8991
NAME DESCRIPTION DOCKER ENDPOINT ...
9092
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock ...
91-
desktop-linux unix:///home/<user>/.docker/desktop/docker.sock ...
93+
desktop-linux unix:///home/<user>/.docker/desktop/docker.sock ...
9294
```
9395

9496
If you have both Docker Desktop and Docker Engine installed on the same machine,
@@ -101,14 +103,15 @@ $ docker context use default
101103
default
102104
Current context is now "default"
103105
```
104-
106+
105107
And use the `desktop-linux` context to interact with Docker Desktop:
106-
108+
107109
```console
108110
$ docker context use desktop-linux
109111
desktop-linux
110112
Current context is now "desktop-linux"
111-
```
113+
```
114+
112115
Refer to the [Docker Context documentation](/manuals/engine/manage-resources/contexts.md) for more details.
113116
{{< /accordion >}}
114117

@@ -117,13 +120,12 @@ Refer to the [Docker Context documentation](/manuals/engine/manage-resources/con
117120
Docker provides `.deb` and `.rpm` packages for the following Linux distributions
118121
and architectures:
119122

120-
| Platform | x86_64 / amd64 |
121-
|:------------------------|:-----------------------:|
122-
| [Ubuntu](ubuntu.md) ||
123-
| [Debian](debian.md) ||
124-
| [Red Hat Enterprise Linux (RHEL)](rhel.md) ||
125-
| [Fedora](fedora.md) ||
126-
123+
| Platform | x86_64 / amd64 |
124+
| :----------------------------------------- | :------------: |
125+
| [Ubuntu](ubuntu.md) ||
126+
| [Debian](debian.md) ||
127+
| [Red Hat Enterprise Linux (RHEL)](rhel.md) ||
128+
| [Fedora](fedora.md) ||
127129

128130
An experimental package is available for [Arch](archlinux.md)-based distributions. Docker has not tested or verified the installation.
129131

@@ -151,7 +153,6 @@ Docker Desktop for Linux runs a Virtual Machine (VM). For more information on wh
151153
152154
### KVM virtualization support
153155

154-
155156
Docker Desktop runs a VM that requires [KVM support](https://www.linux-kvm.org).
156157

157158
The `kvm` module should load automatically if the host has virtualization support. To load the module manually, run:
@@ -186,7 +187,6 @@ irqbypass 16384 1 kvm
186187

187188
#### Set up KVM device user permissions
188189

189-
190190
To check ownership of `/dev/kvm`, run :
191191

192192
```console
@@ -201,13 +201,15 @@ $ sudo usermod -aG kvm $USER
201201

202202
Sign out and sign back in so that your group membership is re-evaluated.
203203

204-
## Where to go next
204+
## Using Docker SDKs with Docker Desktop
205205

206-
- Install Docker Desktop for Linux for your specific Linux distribution:
207-
- [Install on Ubuntu](ubuntu.md)
208-
- [Install on Debian](debian.md)
209-
- [Install on Red Hat Enterprise Linux (RHEL)](rhel.md)
210-
- [Install on Fedora](fedora.md)
211-
- [Install on Arch](archlinux.md)
206+
Docker Desktop for Linux uses a per-user socket instead of the system-wide `/var/run/docker.sock`. Docker SDKs and tools that connect directly to the Docker daemon need the `DOCKER_HOST` environment variable set to connect to Docker Desktop. For configuration details, see [How do I use Docker SDKs with Docker Desktop for Linux?](/manuals/desktop/troubleshoot-and-support/faqs/linuxfaqs.md#how-do-i-use-docker-sdks-with-docker-desktop-for-linux).
212207

208+
## Where to go next
213209

210+
- Install Docker Desktop for Linux for your specific Linux distribution:
211+
- [Install on Ubuntu](ubuntu.md)
212+
- [Install on Debian](debian.md)
213+
- [Install on Red Hat Enterprise Linux (RHEL)](rhel.md)
214+
- [Install on Fedora](fedora.md)
215+
- [Install on Arch](archlinux.md)

content/manuals/desktop/troubleshoot-and-support/faqs/general.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Docker Desktop Windows users can connect to the Docker Engine through a **named
5454

5555
For details, see [Docker Engine API](/reference/api/engine/_index.md).
5656

57+
See the [Linux FAQs](linuxfaqs.md) for Linux specific setup.
58+
5759
### How do I connect from a container to a service on the host?
5860

5961
The host has a changing IP address, or none if you have no network access.

content/manuals/desktop/troubleshoot-and-support/faqs/linuxfaqs.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ title: FAQs for Docker Desktop for Linux
55
linkTitle: Linux
66
tags: [FAQ]
77
aliases:
8-
- /desktop/linux/space/
9-
- /desktop/faqs/linuxfaqs/
8+
- /desktop/linux/space/
9+
- /desktop/faqs/linuxfaqs/
1010
weight: 40
1111
---
1212

@@ -16,32 +16,32 @@ Docker Desktop for Linux runs a Virtual Machine (VM) for the following reasons:
1616

1717
1. To ensure that Docker Desktop provides a consistent experience across platforms.
1818

19-
During research, the most frequently cited reason for users wanting Docker Desktop for Linux was to ensure a consistent Docker Desktop
20-
experience with feature parity across all major operating systems. Utilizing
21-
a VM ensures that the Docker Desktop experience for Linux users will closely
22-
match that of Windows and macOS.
19+
During research, the most frequently cited reason for users wanting Docker Desktop for Linux was to ensure a consistent Docker Desktop
20+
experience with feature parity across all major operating systems. Utilizing
21+
a VM ensures that the Docker Desktop experience for Linux users will closely
22+
match that of Windows and macOS.
2323

2424
2. To make use of new kernel features.
2525

26-
Sometimes we want to make use of new operating system features. Because we control the kernel and the OS inside the VM, we can roll these out to all users immediately, even to users who are intentionally sticking on an LTS version of their machine OS.
26+
Because Docker controls the kernel and the OS inside the VM, Docker can roll these out to all users immediately, even to users who are intentionally sticking on an LTS version of their machine OS.
2727

2828
3. To enhance security.
2929

30-
Container image vulnerabilities pose a security risk for the host environment. There is a large number of unofficial images that are not guaranteed to be verified for known vulnerabilities. Malicious users can push images to public registries and use different methods to trick users into pulling and running them. The VM approach mitigates this threat as any malware that gains root privileges is restricted to the VM environment without access to the host.
30+
Container image vulnerabilities pose a security risk for the host environment. There is a large number of unofficial images that are not guaranteed to be verified for known vulnerabilities. Malicious users can push images to public registries and use different methods to trick users into pulling and running them. The VM approach mitigates this threat as any malware that gains root privileges is restricted to the VM environment without access to the host.
3131

32-
Why not run rootless Docker? Although this has the benefit of superficially limiting access to the root user so everything looks safer in "top", it allows unprivileged users to gain `CAP_SYS_ADMIN` in their own user namespace and access kernel APIs which are not expecting to be used by unprivileged users, resulting in [vulnerabilities](https://www.openwall.com/lists/oss-security/2022/01/18/7).
32+
Why not run rootless Docker? Although this has the benefit of superficially limiting access to the root user so everything looks safer in "top", it allows unprivileged users to gain `CAP_SYS_ADMIN` in their own user namespace and access kernel APIs which are not expecting to be used by unprivileged users, resulting in [vulnerabilities](https://www.openwall.com/lists/oss-security/2022/01/18/7).
3333

3434
4. To provide the benefits of feature parity and enhanced security, with minimal impact on performance.
3535

36-
The VM utilized by Docker Desktop for Linux uses [`VirtioFS`](https://virtio-fs.gitlab.io), a shared file system that allows virtual machines to access a directory tree located on the host. Our internal benchmarking shows that with the right resource allocation to the VM, near native file system performance can be achieved with VirtioFS.
36+
The VM utilized by Docker Desktop for Linux uses [`VirtioFS`](https://virtio-fs.gitlab.io), a shared file system that allows virtual machines to access a directory tree located on the host. Docker's internal benchmarking shows that with the right resource allocation to the VM, near native file system performance can be achieved with VirtioFS.
3737

38-
As such, we have adjusted the default memory available to the VM in Docker Desktop for Linux. You can tweak this setting to your specific needs by using the **Memory** slider within the **Settings** > **Resources** tab of Docker Desktop.
38+
As such, the default memory available to the VM in Docker Desktop for Linux is adjusted. You can tweak this setting to your specific needs by using the **Memory** slider within the **Settings** > **Resources** tab of Docker Desktop.
3939

4040
### How do I enable file sharing?
4141

4242
Docker Desktop for Linux uses [VirtioFS](https://virtio-fs.gitlab.io/) as the
4343
default (and currently only) mechanism to enable file sharing between the host
44-
and Docker Desktop VM.
44+
and Docker Desktop VM.
4545

4646
{{< accordion title="Additional information for Docker Desktop version 4.34 and earlier" >}}
4747

@@ -59,7 +59,7 @@ mappings for IDs greater than 0 in the containers.
5959

6060
| ID in container | ID on host |
6161
| --------------- | -------------------------------------------------------------------------------- |
62-
| 0 (root) | ID of the user running Docker Desktop (e.g. 1000) |
62+
| 0 (root) | ID of the user running Docker Desktop (e.g. 1000) |
6363
| 1 | 0 + beginning of ID range specified in `/etc/subuid`/`/etc/subgid` (e.g. 100000) |
6464
| 2 | 1 + beginning of ID range specified in `/etc/subuid`/`/etc/subgid` (e.g. 100001) |
6565
| 3 | 2 + beginning of ID range specified in `/etc/subuid`/`/etc/subgid` (e.g. 100002) |
@@ -95,6 +95,34 @@ ACL (see `setfacl(1)`) for folders shared with the Docker Desktop VM.
9595

9696
{{< /accordion >}}
9797

98+
### How do I use Docker SDKs with Docker Desktop for Linux?
99+
100+
Docker Desktop for Linux uses a per-user socket located at `~/.docker/desktop/docker.sock` instead of the system-wide `/var/run/docker.sock`. The Docker CLI handles this automatically through the `desktop-linux` context, but Docker SDKs and other tools that connect directly to the Docker daemon also need the `DOCKER_HOST` environment variable set.
101+
102+
Without setting `DOCKER_HOST`, SDKs attempt to connect to `/var/run/docker.sock` and fail with an error like:
103+
104+
```text
105+
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
106+
```
107+
108+
To fix this, set the `DOCKER_HOST` environment variable before running your SDK-based application:
109+
110+
```console
111+
export DOCKER_HOST=unix://$HOME/.docker/desktop/docker.sock
112+
```
113+
114+
Or dynamically retrieve it from the `desktop-linux` context:
115+
116+
```console
117+
export DOCKER_HOST=$(docker context inspect desktop-linux --format '{{ .Endpoints.docker.Host }}')
118+
```
119+
120+
To make this permanent, add the export command to your shell profile (`~/.bashrc`, `~/.zshrc`, or similar):
121+
122+
```console
123+
echo 'export DOCKER_HOST=unix://$HOME/.docker/desktop/docker.sock' >> ~/.bashrc
124+
```
125+
98126
### Where does Docker Desktop store Linux containers?
99127

100128
Docker Desktop stores Linux containers and images in a single, large "disk image" file in the Linux filesystem. This is different from Docker on Linux, which usually stores containers and images in the `/var/lib/docker` directory on the host's filesystem.
@@ -117,7 +145,7 @@ If the disk image file is too large, you can:
117145

118146
To move the disk image file to a different location:
119147

120-
1. Select **Settings** then **Advanced** from the **Resources** tab.
148+
1. Select **Settings** then **Advanced** from the **Resources** tab.
121149

122150
2. In the **Disk image location** section, select **Browse** and choose a new location for the disk image.
123151

content/reference/api/engine/sdk/_index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ For more information, see [Go client reference](https://pkg.go.dev/github.com/mo
4444

4545
For more information, see [Docker Engine Python SDK reference](https://docker-py.readthedocs.io/).
4646

47+
> [!NOTE]
48+
> Docker Desktop for Linux users
49+
>
50+
> Docker Desktop for Linux uses a per-user socket instead of the system-wide `/var/run/docker.sock`. To use Docker SDKs with Docker Desktop for Linux, set the `DOCKER_HOST` environment variable:
51+
>
52+
> ```bash
53+
> export DOCKER_HOST=unix://$HOME/.docker/desktop/docker.sock
54+
> ```
55+
>
56+
> For more details, see [the Linux FAQs](/manuals/desktop/troubleshoot-and-support/faqs/linuxfaqs.md#how-do-i-use-docker-sdks-with-docker-desktop-for-linux).
57+
4758
## View the API reference
4859
4960
You can

0 commit comments

Comments
 (0)