My Digital Garden

Devcontainer spec for Jupyter Notebooks

Devcontainer spec for Jupyter Notebooks

Add the following files to your workspace:


// For format details, see For config options, see the
// README at:
	"name": "Jupyter Data Science Notebooks",
	"build": {
		"dockerfile": "Dockerfile"
	// Features to add to the dev container. More info:
	"features": {
		"": {
			"installZsh": "true",
			"username": "jovyan",
			"userUid": "1000",
			"userGid": "1000",
			"upgradePackages": "true"
	// Use base images default CMD.
	"overrideCommand": false,
	// Forward Jupyter port locally, mark required.
	"forwardPorts": [8888],
	"portsAttributes": {
		"8888": {
			"label": "Jupyter",
			"requireLocalPort": true,
			"onAutoForward": "ignore"
	// Configure tool-specific properties.
	"customizations": {
		// Configure properties specific to VS Code.
		"vscode": {
			// Set *default* container specific settings.json values on container create.
			"settings": {
				"python.defaultInterpreterPath": "/opt/conda/bin/python"
			// Add the IDs of extensions you want installed when the container is created.
			"extensions": ["ms-python.python", "ms-toolsai.jupyter"]
	// Use 'postCreateCommand' to run commands after the container is created.
	// "postCreateCommand": "pip3 install --user -r requirements.txt",

	// Configure tool-specific properties.
	// "customizations": {},

	// Uncomment to connect as root instead. More info:
	// "remoteUser": "root"



USER root
# Generally, Dev Container Features assume that the non-root user (in this case jovyan)
# is in a group with the same name (in this case jovyan). So we must first make that so.
RUN groupadd jovyan \
    && usermod -g jovyan -a -G users jovyan

USER jovyan


Also works in GitHub CodeSpaces

See also