Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target not overwritten when using features #120

Closed
chrmarti opened this issue Aug 12, 2022 · 4 comments
Closed

Target not overwritten when using features #120

chrmarti opened this issue Aug 12, 2022 · 4 comments
Assignees
Labels
bug Something isn't working important verified
Milestone

Comments

@chrmarti
Copy link
Contributor

Reported by @sajaysurya in microsoft/vscode-dev-containers#1519:

Currently the docker-from-docker feature doesn't support multistage Dockerfiles

Relates to: Remote - Containers

It works well with the following Dockerfile

FROM python:3.10.5 
RUN apt-get update -q \
    && apt-get install -q -y --no-install-recommends \
        sudo
# add non-root user with sudo access (sudo required by docker-from-docker feature)
RUN adduser vscode
RUN echo vscode ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/vscode \
    && chmod 0440 /etc/sudoers.d/$USERNAME
USER vscode

and the following .devcontainer.json file

        "dockerFile": "Dockerfile",
        "containerUser": "vscode",
	"features": {
		"docker-from-docker": {
			"version": "latest"
		}
	}

It actually works with a named stage in the Dockerfile like

FROM python:3.10.5 AS vscode_dev
RUN apt-get update -q \
    && apt-get install -q -y --no-install-recommends \
        sudo
# add non-root user with sudo access (sudo required by docker-from-docker feature)
RUN adduser vscode
RUN echo vscode ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/vscode \
    && chmod 0440 /etc/sudoers.d/$USERNAME
USER vscode

as long as the build target in not explicitly mentioned in the .devcontainer.json file

        "dockerFile": "Dockerfile",
	"build": { "target": "vscode_dev" }, <--- NOTE: works without this line!
        "containerUser": "vscode",
	"features": {
		"docker-from-docker": {
			"version": "latest"
		}
	}
@chrmarti
Copy link
Contributor Author

PR #121 up for review.

@chrmarti
Copy link
Contributor Author

Fix is available in Dev Containers CLI 0.10.1, 0.12.0 and Remote-Containers 0.245.1 and 0.248.0-pre-release.

@rzhao271
Copy link
Contributor

I'm unable to repro the original issue on Windows with older Remote-Containers versions. What are some verification steps for this issue?

@rzhao271 rzhao271 added verification-steps-needed Steps to verify are needed for verification and removed verified labels Aug 26, 2022
@chrmarti
Copy link
Contributor Author

chrmarti commented Sep 1, 2022

@rzhao271 Thanks for the ping, the following show repro and verify it:

With the following with 0.247.0-pre-release there is no gh command in the dev container, with the fix in later versions gh is available:

devcontainer.json:

{
	"build": {
		"dockerfile": "Dockerfile",
		"target": "vscode_dev"
	},
	"features": {
		"github-cli": "latest"
	}
}

Dockerfile:

FROM ubuntu:latest AS vscode_dev

@chrmarti chrmarti removed the verification-steps-needed Steps to verify are needed for verification label Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working important verified
Projects
None yet
Development

No branches or pull requests

3 participants