spec icon indicating copy to clipboard operation
spec copied to clipboard

does the spec for `build` follow the docs

Open 8de2fdb0 opened this issue 1 year ago • 4 comments

Based of the docs it seems build and image can be used together to use image as the image tag when runningdocker build. The JSON spec doesn't allow both values together, but the cli does it actually exactly as the docs say.

{
...
 "image": "my-devimage",
 "build": {
        "dockerfile": "Dockerfile",
    }
}

8de2fdb0 avatar May 21 '25 06:05 8de2fdb0

squabbleup-holdup-mybisssh-sideways-feva-onit-clockinit-pipedown-kids-yehaw-fictional-fed>criminal-feelgood-sqabbleup

Roboticsense00 avatar May 21 '25 22:05 Roboticsense00

Hi @8de2fdb0, The documentation indicates that you can use either the Dockerfile specification or the image tag specification, but not both simultaneously. If you prefer to use a custom Dockerfile, you should use the build option. Alternatively, you can specify an image tag to directly use a particular image for your DevContainer.

The image option is used to specify a pre-built image for your development container.

The build option (with a Dockerfile) allows you to build a custom image for your container from source using the specified Dockerfile.

sireeshajonnalagadda avatar Jul 01 '25 09:07 sireeshajonnalagadda

Ok I am just asking since https://github.com/devcontainers/cli and vscode will build an image using the tag from the image field and the Dockerfile speicified in build.dockerfile. So i was wondering why these implementations do exactly the same and the json spec show that these fields are not valid together.

8de2fdb0 avatar Jul 01 '25 10:07 8de2fdb0

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See License.txt in the project root for license information.

ARG VARIANT="16-bullseye" FROM mcr.microsoft.com/devcontainers/typescript-node:1-${VARIANT}

RUN mkdir -p /workspaces && chown node:node /workspaces

ARG USERNAME=node USER $USERNAME

Save command line history

RUN echo "export HISTFILE=/home/$USERNAME/commandhistory/.bash_history" >> "/home/$USERNAME/.bashrc"
&& echo "export PROMPT_COMMAND='history -a'" >> "/home/$USERNAME/.bashrc"
&& mkdir -p /home/$USERNAME/commandhistory
&& touch /home/$USERNAME/commandhistory/.bash_history
&& chown -R $USERNAME /home/$USERNAME/commandhistory

White01-bot1 avatar Jul 01 '25 15:07 White01-bot1