I got the same issue before.

To solve this problem, you should use F1 > Dev Containers: Rebuild Container rather than F1 > Dev Containers: Rebuild Container Without Cache.

Then it should be able to use a local image. Tested on my local and worked fine.

Answer from Zac on Stack Overflow
🌐
Docker Hub
hub.docker.com › r › microsoft › vscode-devcontainers
microsoft/vscode-devcontainers - Docker Image
A link is available in the .devcontainer/devcontainer.json file added to your folder. Run Remote-Containers: Reopen in Container to use it locally, or Codespaces: Rebuild Container from within a codespace. See the Remote - Containers⁠ and GitHub Codespaces⁠ documentation for more information. You are also free to use these images on their own as you see fit. For example: docker run -it --init --rm mcr.microsoft.com/vscode/devcontainers/base:0-buster Copy
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › create-dev-container
Create a Dev Container
November 3, 2021 - An image is like a mini-disk drive with various tools and an operating system pre-installed. You can pull images from a container registry, which is a collection of repositories that store images.
Discussions

visual studio code - How can I use a local image using vscode-devcontainer - Stack Overflow
Then it should be able to use a local image. Tested on my local and worked fine. ... Sign up to request clarification or add additional context in comments. ... If OP is using "Rebuild without Cache" it would be causing problems indeed, but using "Rebuild Container" also doesn't solve the problem. The root of the problem is that VSCode's DevContainer ... More on stackoverflow.com
🌐 stackoverflow.com
docker - vscode devcontainers - why are two images built? - Stack Overflow
im using a remote container as my dev environment. so essentially in my project i have a Dockerfile, docker-compose.yml and my devcontainer.json that vscode uses to build, start and launch into the More on stackoverflow.com
🌐 stackoverflow.com
How to Creating Dev Container from docker image in private registry?
As u/pretzelfisch said, create a dockerfile that uses your internal image and add anything else you need. Devcontainers have 'features' - a bountiful set of resources, many linters. Another tip is, after installing any extensions, right click on it and "add it to devcontainer.json" Take the time to learn about devcontainers, they are invaluable - I do all my dev in them, multiple different golang / python / c++ environments, no pollution or cross-contamination. More on reddit.com
🌐 r/vscode
9
0
September 19, 2025
docker - DevContainer attatch to new image container in vscode? - Stack Overflow
I use wsl environment and vscode editor.I reopen project in devcontainer and make some changes to current container,so I use docker commit to create a new image.But current container is still use o... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › containers
Developing inside a Container
November 3, 2021 - Once you've built your image, you can push it to a container registry (like the Azure Container Registry, GitHub Container Registry, or Docker Hub) and reference it directly. You can use the GitHub Action in the devcontainers/ci repository to help you reuse dev containers in your workflows.
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › tutorial
Dev Containers tutorial
November 3, 2021 - Finally your Visual Studio Code environment is installed and configured again according to settings in the devcontainer.json. For example, the dev container in this example installs the streetsidesoftware.code-spell-checker extension. Note: Additional configuration will already be added to the container based on what's in the base image. For example, we see the streetsidesoftware.code-spell-checker extension above, and the container will also include "dbaeumer.vscode-eslint" as that's part of mcr.microsoft.com/devcontainers/typescript-node.
Top answer
1 of 2
1

I got the same issue before.

To solve this problem, you should use F1 > Dev Containers: Rebuild Container rather than F1 > Dev Containers: Rebuild Container Without Cache.

Then it should be able to use a local image. Tested on my local and worked fine.

2 of 2
-1

Your specific error is:

=> ERROR [internal] load metadata for docker.io/library/demo:f  1.4s
[...]
ERROR: failed to solve: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

You don't actually have a demo:focal image in your docker local image cache is what this means, you probably named it something slightly different.


VSCode just uses docker (based on your VSCode settings configuration apparently) to implicitly build an image here, so it's temporarily constructing a Dockerfile that starts with FROM ${image} and then passing it to docker buildx build.

What you're seeing is docker checking the local image cache for demo:focal, not finding an image with that exact name and version, using the fallback behavior for image names that don't start with a URL+path and adding the default docker.io/library/ to the name, still not finding docker.io/library/demo:focal in the local image cache, and then trying to get the image from the registry since it's missing from the local image cache. Since your image name didn't have a registry URL, which is required to be able to pull, it uses the built-in fallback behavior and adds docker.io/library/ and then tries to pull from docker.io/library/demo:focal.

Apparently the docker.io registry is returning an "access denied" error if you try to do a docker pull docker.io/library/demo:focal.

So to fix this, you need to:

  1. Have the image you want already in your docker local image cache (shows up with the exact same name in docker image ls results)
  2. Use the identical matching name in your devcontainer.json for the "image" field.
🌐
GitHub
github.com › devcontainers › images
GitHub - devcontainers/images: Repository for pre-built dev container images published under mcr.microsoft.com/devcontainers · GitHub
This repository supplies images that may be used in dev container configurations that follow the spec. A devcontainer.json file is similar to launch.json for debugging, but designed to launch (or attach to) a development container instead.
Starred by 2K users
Forked by 904 users
Languages   Shell 46.4% | JavaScript 42.9% | Dockerfile 7.8% | Java 1.0% | Python 0.7% | C# 0.3%
🌐
GitHub
github.com › microsoft › vscode-dev-containers
GitHub - microsoft/vscode-dev-containers: NOTE: Most of the contents of this repository have been migrated to the new devcontainers GitHub org (https://github.com/devcontainers). See https://github.com/devcontainers/template-starter and https://github.com/devcontainers/feature-starter for information on creating your own! · GitHub
November 30, 2023 - The definitions describe the appropriate container image, runtime arguments for starting the container, and VS Code extensions that should be installed. Each provides a container configuration file (devcontainer.json) and other needed files that you can drop into any existing folder as a starting point for containerizing your project. You can use the Add Development Container Configuration Files... command to add one to your project or codespace. The vscode-remote-try-* repositories may also be of interest if you are looking for complete sample projects.
Starred by 4.7K users
Forked by 1.4K users
Languages   Shell 78.1% | Dockerfile 8.2% | JavaScript 7.0% | Jupyter Notebook 4.4% | Python 0.9% | C# 0.4%
Find elsewhere
🌐
Medium
medium.com › versent-tech-blog › introduction-to-dev-containers-4c01cb1752a0
Introduction to Dev Containers. An introduction to Dev Containers in… | by Mathew Hemphill | Versent Tech Blog | Medium
June 19, 2024 - { "name": "Java Development", "image": ... [ "vscjava.vscode-java-pack" ] } } } This configures a container (named “Java Development”) based on an image provided by Microsoft on Docker Hub....
🌐
Docker Hub
hub.docker.com › r › microsoft › devcontainers-base
microsoft/devcontainers-base - Docker Image
mcr.microsoft.com/devcontainers/base:alpine (latest) ... Refer to this guide⁠ for more details. You can decide how often you want updates by referencing a semantic version⁠ of each image. For example: ... See history⁠ for information on the contents of each version and here for a complete list of available tags⁠. Beyond git, this image / Dockerfile includes zsh, Oh My Zsh!⁠, a non-root vscode user with sudo access, and a set of common dependencies for development.
Top answer
1 of 1
5

I was wondering about the same thing, so I did the following:

Steps

  1. I printed out the image history, only printing out the column that shows the actual docker file statements. See https://docs.docker.com/config/formatting/ and https://docs.docker.com/engine/reference/commandline/history/
docker image history PUTIMAGE_HASH_HERE_FOR_IMAGE_NOT_ENDING_IN_UID --no-trunc --format "table {{.CreatedBy}}" > image_wo_uid.txt

docker image history PUTIMAGE_HASH_HERE_FOR_IMAGE_WITH_UID_AT_END --no-trunc --format "table {{.CreatedBy}}" > image_uid.txt
  1. Then diff the two: diff image_wo_uid.txt image_uid.txt

  2. That gives you something like (note: reverse chronological order):

1a2,9
> USER vscode
> ARG IMAGE_USER
> RUN |3 REMOTE_USER=vscode NEW_UID=1000 NEW_GID=1000 /bin/sh -c eval $(sed -n "s/${REMOTE_USER}:[^:]*:\([^:]*\):\([^:]*\):[^:]*:\([^:]*\).*/OLD_UID=\1;OLD_GID=\2;HOME_FOLDER=\3/p" /etc/passwd);  eval $(sed -n "s/\([^:]*\):[^:]*:${NEW_UID}:.*/EXISTING_USER=\1/p" /etc/passwd);  eval $(sed -n "s/\([^:]*\):[^:]*:${NEW_GID}:.*/EXISTING_GROUP=\1/p" /etc/group);  if [ -z "$OLD_UID" ]; then   echo "Remote user not found in /etc/passwd ($REMOTE_USER).";  elif [ "$OLD_UID" = "$NEW_UID" -a "$OLD_GID" = "$NEW_GID" ]; then   echo "UIDs and GIDs are the same ($NEW_UID:$NEW_GID).";  elif [ "$OLD_UID" != "$NEW_UID" -a -n "$EXISTING_USER" ]; then   echo "User with UID exists ($EXISTING_USER=$NEW_UID).";  elif [ "$OLD_GID" != "$NEW_GID" -a -n "$EXISTING_GROUP" ]; then   echo "Group with GID exists ($EXISTING_GROUP=$NEW_GID).";  else   echo "Updating UID:GID from $OLD_UID:$OLD_GID to $NEW_UID:$NEW_GID.";   sed -i -e "s/\(${REMOTE_USER}:[^:]*:\)[^:]*:[^:]*/\1${NEW_UID}:${NEW_GID}/" /etc/passwd;   if [ "$OLD_GID" != "$NEW_GID" ]; then    sed -i -e "s/\([^:]*:[^:]*:\)${OLD_GID}:/\1${NEW_GID}:/" /etc/group;   fi;   chown -R $NEW_UID:$NEW_GID $HOME_FOLDER;  fi; # buildkit
> SHELL [/bin/sh -c]
> ARG NEW_GID
> ARG NEW_UID
> ARG REMOTE_USER
> USER root

Conclusion

  • The image ending in uid is switching to a non-root user and is taking extra measures to guarantee that the uid and guid are each 1000 (see the long RUN statement). It has a bunch of error handling to output an error if another user/group already exists at 1000.
  • I'm guessing the devcontainer programmers are doing this because they can't be sure what base image is being used and thus USER vscode might not be at 1000/1000 for uid/guid.

Notes

  • Details can vary by Linux distro (I think), but basically, if you guarantee your user ids/group ids are at 1000 or above you are in 'non-system user' (=regular user) uid space. Example discussion: https://ubuntuforums.org/showthread.php?t=1740376
  • Some people recommend moving to 10000, not 1000, to have a lower probability of running into a pre-existing user at the 1000 range, which is quite likely, since the first non-system user will be at 1000, if no other steps are taken. Example discussion: https://news.ycombinator.com/item?id=25621610
  • I'm not sure why the extra code doesn't first determine the first available uids/guids above 1000 and use those instead of 1000, just in case 1000 is already taken.
🌐
GitHub
docs.github.com › codespaces › setting-up-your-project-for-codespaces › introduction-to-dev-containers
Introduction to dev containers - GitHub Docs
This is followed by commands that are run during the image creation process, for example to install software packages. The Dockerfile for a dev container is typically located in the .devcontainer folder, alongside the devcontainer.json in which it is referenced.
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › tips-and-tricks
Dev Containers Tips and Tricks
November 3, 2021 - Add "github.copilot.chat.codeGeneration.instructions" directly in your devcontainer.json · We publish dev container resources (like images and Features) to make the process of creating and connecting to dev containers even easier, and we now include custom instructions in these files.
🌐
Reddit
reddit.com › r/vscode › how to creating dev container from docker image in private registry?
r/vscode on Reddit: How to Creating Dev Container from docker image in private registry?
September 19, 2025 -

I'm having a hard time finding instructions on creating a dev container from an existing image. At my employers, we have a private registry, say at docker.internal.domain where the image sits. Let's say the image is "docker.internal.domain/devops-utilties:latest"

I want to use that image as a base for my dev container, installing VS code extensions into it for linting and running tests.

But I can only find instructions for using predefined images . Are the any templates or examples I can use to make a dev container.json and related files needed to build and run a dev container image?

I'd like to do this as some linters like ansible-lint are throwing errors since the path to files like ansible.cfg or the vault password file are different outside the container then inside the container. If I can have the linters running inside the container, problem solved!

Note: I'm a complete noob at this , so if there is a better way, I'm open to hear it!

Do note that the way the utilities container works is you run a wrapper script that sets up environment variable, then executes docker compose run -rm service-name to start the container, which opens an interactive shell for the user to execute command line utilities from.

🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › devcontainer-cli
Dev Container CLI
November 3, 2021 - See documentation for your image registry (such as Azure Container Registry, GitHub Container Registry, or Docker Hub) for information on image naming and additional steps like authentication. devcontainer build --workspace-folder <my_repo> --push true --image-name <my_image_name>:<optional_image_version>
🌐
Visual Studio Code
code.visualstudio.com › blogs › 2022 › 09 › 15 › dev-container-features
Custom Dev Container Features
September 15, 2022 - Along with the new Features repository, we recently open sourced a new devcontainers/images repository where we host a specific set of images that were previously in the vscode-dev-containers repository.
🌐
GitHub
github.com › ohioit › vscode-devcontainer-base
GitHub - ohioit/vscode-devcontainer-base: Base docker image for Visual Studio Code Development Containers
Then, create a Dockerfile in .devcontainer using the base image, like this: FROM docker.artifactory.oit.ohio.edu/ais/vscode-devcontainer-base:VERSION # Customize the image as root # Optionally customize the image as vscode USER 1000 # Make sure you switch back to root after USER 0 # Do not set an entrypoint
Author   ohioit
🌐
Development Containers
containers.dev › implementors › json_reference
Dev Container metadata reference
Metadata properties marked with a 🏷️️ can be stored in the devcontainer.metadata container image label in addition to devcontainer.json.
🌐
Microsoft Community
techcommunity.microsoft.com › microsoft community hub › communities › topics › education sector › educator developer blog
Using Visual Studio Code from a docker image locally or remotely via VS Online | Microsoft Community Hub
June 17, 2020 - The following VSCode Repo contains various container deployments https://github.com/microsoft/vscode-dev-containers/tree/master/containers this repository contains a set of dev container definitions to help get you up and running with a containerized environment. The definitions describe the appropriate container image, runtime arguments for starting the container, and VS Code extensions that should be installed. Each provides a container configuration file (devcontainer.json) and other needed files that you can drop into any existing folder as a starting point for containerizing your project.
🌐
Ben Selby
benmatselby.dev › post › vscode-dev-containers
Setting up a VS Code Dev Container · Ben Selby
March 21, 2021 - The Dockerfile is dropped into the .devcontainer folder within your project. If you have used the VS Code configuration screen, you’re likely to be using a base image provided by Microsoft.