microsoft / microsoft/vscode-remote-release

Dev Containers - "Attach to Running Container..." Error: ENAMETOOLONG: name too long

Open
#8,563 0 comments 0 reactions 1 assignee View on GitHub

@chrmarti is already working on this.

Since Dec 16, 2024.

bug containers
Dominant language
Dockerfile
Stars
4.2k
Forks
470
Avg merge
1d 1h
Merged PRs (30d)
1

Description

Sorry for my bad English, I use a translator to make less mistakes.

  • VSCode Version: 1.78.2

  • Local OS Version: Linux Mint 21.1 Vera

  • Remote Extension/Connection Type: Containers (Dev Containers 0.294.0)

  • Logs:

[18 ms] Dev Containers 0.294.0 in VS Code 1.78.2 (b3e4e68a0bc097f0ae7907b217c1119af9e03435).
[18 ms] Start: Résolution à distance
[19 ms] Setting up container: /test_enametoolong
[19 ms] Context: rootless
[25 ms] Start: Run: docker inspect --type container /test_enametoolong
[45 ms] Error: ENAMETOOLONG: name too long, open '/home/user/.config/Code/User/globalStorage/ms-vscode-remote.remote-containers/imageConfigs/custom-registry-url.cloud%2fgroup%2fprojects%2fproject-category%2fmain-long-project-name%2fother-long-project-name%2flong-project-image-name%3alatest.json'
[46 ms] Exit code ENAMETOOLONG

Steps to Reproduce:

To reproduce the bug, you need a Docker image on a registry with an extended path.
I've replaced my private registry path to avoid disclosing private information.

  1. docker run -d --name=test_enametoolong custom-registry-url.cloud/group/projects/project-category/main-long-project-name/other-long-project-name/long-project-image-name:latest
  2. Try "Attach to Running Container..."

Does this issue occur when you try this locally?: Yes
Does this issue occur when you try this locally and all extensions are disabled?: Yes


Temporary solution (imageConfigs only)

The problem is the name of the imageConfigs json file, which is too long because it's based on the name of the Docker image (including the entire registry path).

To unblock the problem on my environment, I modified the file .vscode/extensions/ms-vscode-remote.remote-containers-0.294.0/dist/extension/extension.js to change the name of the json file (replacing it with its md5 hash).

Here are the steps for my modifications:

  1. Search for md5 in the file to find the function name (a few characters before the md5 string) already present in the extension (NK for version 0.294.0).
  2. Search for imageConfigs, then .json a few characters further on.
  3. Call the md5 function (obtained in step 1) on the file name (example: ${xue(t)}.json becomes ${NK(xue(t))}.json).

To automate this modification :
sed -i "s/\(imageConfigs\")}[^\$]*\)\${\([^}]*\)}/\1\${$(grep -Po ' \K(\w+)(?=\(.\)[^(]+\("md5")' extension.js)(\2)}/g" extension.js


Can you make the necessary changes to keep the imageConfigs json file names under the maximum length?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.