1 Using with VSCode and Remote Containers
Or Fleisher edytuje tę stronę 2021-06-22 09:44:30 -04:00

Instructions

  1. Create a project folder and open it in VS Code. Add a .devcontainer folder.
  2. Create a devcontainer.json file inside it with the content as shown below.
  3. Also create an empty .config/blender folder.
  4. Execute the container by pressing Ctrl+⇧Shift+P and run the command Remote-Containers: Reopen in Container.
  5. From the integrated terminal, run blender.

Folder structure

This is the folder structure before running the container.

.
├── .devcontainer
│   └── devcontainer.json
│   ├── .config
│   │   └── blender
├── Docker (Not required)
│   └── Dockerfile
Folder structure after execution After running the container once, including running Blender, the folder structure should look something similar to this:
 .
├── blender_file.blend
├── .devcontainer
│   ├── .config
│   │   └── blender
│   │       └── 2.92
│   │           └── config
│   │               ├── platform_support.txt
│   │               ├── recent-files.txt
│   │               └── userpref.blend
│   └── devcontainer.json
├── Docker
│   └── Dockerfile

devcontainer.json

{
	"name": "blender",
	//// Use this if you use a custom image.
	//"build": {
	//	"dockerfile": "../Docker/Dockerfile",
	// },
	// Use this if you only need to run the image directly. 
	"image": "nytimes/blender:latest",
	"settings": {
		"terminal.integrated.shell.linux": "/bin/bash"
	},

	"workspaceMount": "source=${localWorkspaceFolder},target=/root/${localWorkspaceFolderBasename},type=bind", 
	"workspaceFolder": "/root/${localWorkspaceFolderBasename}",
	// We also mount the config folder from the host system. This way, settings 
	// inside the container are kept between runs.
	"mounts": [
		"source=${localWorkspaceFolder}/.devcontainer/.config/blender,target=/root/.config/blender/,type=bind"
	],
	"runArgs": [
		"-it", 
		"--rm", // Removes the container on exit. Remove this if you want the container to keep running.
		"--gpus", "all",
		"-v", "/tmp/.X11-unix:/tmp/.X11-unix:rw", 
		"-v", "/tmp/.docker.xauth:/tmp/.docker.xauth:rw", 
		"-e", "DISPLAY=${localEnv:DISPLAY}", 
		"-e", "XAUTHORITY=/tmp/.docker.xauth", 
		"--device", "/dev/dri/card0:/dev/dri/card0"
	],
	"extensions": []
}

See PR for more information about this guide