mathworks-ref-arch / matlab-dockerfile

Create a docker container that contains a MATLAB install
Other
341 stars 96 forks source link

How to run Matlab as a VSCode DevContainer #58

Closed NicolasRouquette closed 3 months ago

NicolasRouquette commented 1 year ago

I would like to run Matlab in a container using a "Development Container"; see: https://containers.dev/

I know that I can start Matlab in a container using this mechanism: https://www.mathworks.com/help/cloudcenter/ug/matlab-container-on-docker-hub.html

When developing Matlab code where I have cloned a repository on the host, I have to specify a docker mount option to make my repository clone available in the container.

This is a lot simpler with the "Development Container"! With ".devcontainer/devcontainer.js" file that specifies the container image -- e.g. https://hub.docker.com/r/mathworks/matlab, I should be able to run Matlab in a container with either the "-browser" and have the Development Container automatically open a browser on the Matlab container.

I made a simple test here: https://github.com/NicolasRouquette/matlab-devcontainer

The Dev Container spec is simple:

// Doc: https://containers.dev/implementors/json_reference/#general-properties
{
  "name": "matlab R2022b",
  "image": "mathworks/matlab:r2022b",
  "forwardPorts": [6080],
  "portsAttributes": {
        "6080": {"label": "noVNC Ubuntu Desktop Root Display", "onAutoForward": "openBrowser"}
  },
  "postStartCommand": "/usr/bin/tini -- matlab -browser"

}

With Visual Studio Code's https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers when I start the container and click on "Show Log",

Running the postStartCommand from devcontainer.json...

[4458 ms] Start: Run in container: /bin/sh -c -browser
/bin/sh: 0: Illegal option -r
[4706 ms] postStartCommand failed with exit code 2. Skipping any further user-provided commands.
Done. Press any key to close the terminal.
[46 ms] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer
[163 ms] Start: Resolving Remote
[167 ms] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer
[277 ms] Start: Run: wsl -d Ubuntu-20.04 -e /bin/sh -c cd '/opt/local/github.autonomica/matlab-devcontainer' && /bin/sh
[285 ms] Start: Run in host: id -un
[329 ms] nfr
[329 ms] 
[329 ms] Start: Run in host: cat /etc/passwd
[331 ms] Start: Run in host: echo ~
[331 ms] /home/nfr
[331 ms] 
[332 ms] Start: Run in host: test -x '/home/nfr/.vscode-remote-containers/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node'
[332 ms] 
[333 ms] 
[333 ms] Exit code 1
[333 ms] Start: Run in host: test -x '/home/nfr/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node'
[334 ms] 
[334 ms] 
[334 ms] Start: Run in host: test -f '/home/nfr/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node_modules/node-pty/package.json'
[335 ms] 
[335 ms] 
[335 ms] Start: Run in host: test -f '/home/nfr/.vscode-remote-containers/dist/vscode-remote-containers-server-0.266.1.js'
[336 ms] 
[336 ms] 
[338 ms] userEnvProbe: loginInteractiveShell (default)
[338 ms] userEnvProbe shell: /bin/bash
[425 ms] userEnvProbe PATHs:
Probe:     '/home/nfr/.local/bin:/home/nfr/.sdkman/candidates/sbt/current/bin:/home/nfr/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/Program Files (x86)/GnuPG/bin:/mnt/c/Program Files/MATLAB/R2022a/runtime/win64:/mnt/c/Program Files/MATLAB/R2022a/bin:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/Microsoft VS Code Insiders/bin:/mnt/c/Program Files (x86)/Pulse Secure/VC142.CRT/X64/:/mnt/c/Program Files (x86)/Pulse Secure/VC142.CRT/X86/:/mnt/c/Program Files (x86)/Common Files/Pulse Secure/TNC Client Plugin/:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Users/nfr/scoop/apps/krew/current/.krew/bin:/mnt/c/Users/nfr/scoop/apps/krew/current:/mnt/c/Users/nfr/.elan/bin:/mnt/c/Users/nfr/scoop/apps/openjdk17/current/bin:/mnt/c/Users/nfr/.pyenv/pyenv-win/bin:/mnt/c/Users/nfr/.pyenv/pyenv-win/shims:/mnt/c/Users/nfr/scoop/apps/nodejs/current/bin:/mnt/c/Users/nfr/scoop/apps/nodejs/current:/mnt/c/Users/nfr/scoop/apps/maven/current/bin:/mnt/c/Users/nfr/scoop/shims:/mnt/c/Users/nfr/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/nfr/AppData/Local/Programs/oh-my-posh/bin:/mnt/c/Users/nfr/AppData/Local/JetBrains/Toolbox/scripts:/mnt/c/Users/nfr/AppData/Roaming/Code/User/globalStorage/ms-vscode-remote.remote-containers/cli-bin:/mnt/d/tools/cue-0.4.3:/mnt/c/Users/nfr/.dotnet/tools:/mnt/c/Users/nfr/.pyenv/pyenv-win/versions/3.9.13/Scripts:/mnt/c/Users/nfr/.pyenv/pyenv-win/versions/3.9.13:/mnt/c/users/nfr/appdata/roaming/python/scripts:/snap/bin:/usr/local/go/bin'
Container: None
[426 ms] Setting up container for folder or workspace: /opt/local/github.autonomica/matlab-devcontainer
[428 ms] Start: Check Docker is running
[428 ms] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[501 ms] Server API version: 1.41
[502 ms] Start: Run in Host: docker volume ls -q
[579 ms] Start: Run in Host: docker ps -q -a --filter label=vsch.local.folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer --filter label=vsch.quality=stable
[651 ms] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer
[725 ms] Start: Run in Host: docker inspect --type container f99f7d01bcb0
[805 ms] Start: Run in Host: /home/nfr/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /opt/local/github.autonomica/matlab-devcontainer --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer --log-level debug --log-format json --config /opt/local/github.autonomica/matlab-devcontainer/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[963 ms] (node:27320) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[963 ms] (Use `node --trace-deprecation ...` to show where the warning was created)
[965 ms] @devcontainers/cli 0.25.2. Node.js v16.14.2. linux 5.10.102.1-microsoft-standard-WSL2 x64.
[965 ms] Start: Run: docker buildx version
[1092 ms] github.com/docker/buildx v0.9.1 ed00243a0ce2a0aee75311b06e32d33b44729689
[1092 ms] 
[1092 ms] Start: Resolving Remote
[1095 ms] Start: Run: git rev-parse --show-cdup
[1099 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer
[1177 ms] Start: Run: docker inspect --type container f99f7d01bcb0
[1251 ms] Start: Starting container
[1251 ms] Start: Run: docker start f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6
[1786 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer
[1864 ms] Start: Run: docker inspect --type container f99f7d01bcb0
[1944 ms] Start: Inspecting container
[1945 ms] Start: Run: docker inspect --type container f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6
[2026 ms] Start: Run in container: /bin/sh
[2029 ms] Start: Run in container: uname -m
[2189 ms] x86_64
[2190 ms] 
[2190 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[2191 ms] NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[2191 ms] 
[2192 ms] Start: Run in container: cat /etc/passwd
[2194 ms] Start: Run in container: test -f '/var/devcontainer/.patchEtcEnvironmentMarker'
[2195 ms] 
[2195 ms] 
[2195 ms] Start: Run in container: test -f '/var/devcontainer/.patchEtcProfileMarker'
[2196 ms] 
[2196 ms] 
[2200 ms] Start: Run in Host: docker inspect --type container f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6
[2277 ms] Start: Run in Host: /home/nfr/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /opt/local/github.autonomica/matlab-devcontainer --id-label devcontainer.local_folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer --container-id f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 --log-level debug --log-format json --config /opt/local/github.autonomica/matlab-devcontainer/.devcontainer/devcontainer.json --mount-workspace-git-root true
[2435 ms] (node:27628) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[2435 ms] (Use `node --trace-deprecation ...` to show where the warning was created)
[2438 ms] @devcontainers/cli 0.25.2. Node.js v16.14.2. linux 5.10.102.1-microsoft-standard-WSL2 x64.
[2438 ms] Start: Run: git rev-parse --show-cdup
[2444 ms] Start: Run: docker inspect --type container f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6
[2526 ms] Start: Run in Host: /home/nfr/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /opt/local/github.autonomica/matlab-devcontainer --id-label devcontainer.local_folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer --container-id f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 --log-level debug --log-format json --config /opt/local/github.autonomica/matlab-devcontainer/.devcontainer/devcontainer.json --include-merged-configuration --mount-workspace-git-root true
[2685 ms] (node:27667) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[2685 ms] (Use `node --trace-deprecation ...` to show where the warning was created)
[2688 ms] @devcontainers/cli 0.25.2. Node.js v16.14.2. linux 5.10.102.1-microsoft-standard-WSL2 x64.
[2688 ms] Start: Run: git rev-parse --show-cdup
[2694 ms] Start: Run: docker inspect --type container f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6
[2779 ms] Start: Inspecting container
[2779 ms] Start: Run in Host: docker inspect --type container f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6
[2864 ms] Start: Run in Host: docker exec -i -u matlab -e VSCODE_REMOTE_CONTAINERS_SESSION=eeb8c827-e07d-4f71-8548-61e8b590dc591675144612810 f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 /bin/sh
[2867 ms] Start: Run in container: uname -m
[3068 ms] x86_64
[3068 ms] 
[3068 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[3070 ms] NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[3070 ms] 
[3071 ms] Start: Run in container: cat /etc/passwd
[3073 ms] Start: Setup shutdown monitor
[3074 ms] Forking shutdown monitor: c:\Users\nfr\.vscode\extensions\ms-vscode-remote.remote-containers-0.266.1\dist\shutdown\shutdownMonitorProcess \\.\pipe\vscode-remote-containers-032d9fa9690d306d595dca1b7425bc9a5518c753-sock singleContainer Debug c:\Users\nfr\AppData\Roaming\Code\logs\20230130T133524\window20\exthost\ms-vscode-remote.remote-containers 1675144613338
[3086 ms] Start: Run in container: test -d /home/matlab/.vscode-server
[3088 ms] 
[3088 ms] 
[3088 ms] Start: Run in container: test ! -f '/home/matlab/.vscode-server/data/Machine/.writeMachineSettingsMarker' && set -o noclobber && mkdir -p '/home/matlab/.vscode-server/data/Machine' && { > '/home/matlab/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null
[3091 ms] 
[3092 ms] 
[3092 ms] Exit code 1
[3092 ms] Start: Run in container: cat /home/matlab/.vscode-server/data/Machine/settings.json
[3094 ms] {
        "remote.portsAttributes": {
                "6080": {
                        "label": "noVNC Ubuntu Desktop Root Display",
                        "onAutoForward": "openBrowser"
                }
        }
}
[3094 ms] 
[3095 ms] Start: Run in container: test -d /home/matlab/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534
[3097 ms] 
[3097 ms] 
[3097 ms] Start: Run in container: test -d /vscode/vscode-server/bin/linux-x64/97dec172d3256f8ca4bfb2143f3f76b503ca0534
[3099 ms] 
[3099 ms] 
[3099 ms] Start: Run in Host: docker exec -i -u root f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 /bin/sh
[3100 ms] Start: Launching Dev Containers helper.
[3100 ms] ssh-agent: SSH_AUTH_SOCK in container (/tmp/vscode-ssh-auth-7e3c21afde7bf776327103b55e404cfd512793a1.sock) forwarded to local host (\\.\pipe\openssh-ssh-agent).
[3100 ms] Start: Run in Host: gpgconf --list-dir agent-extra-socket
[3102 ms] Start: Run in container: touch '/vscode/vscode-server/bin/linux-x64/97dec172d3256f8ca4bfb2143f3f76b503ca0534'
[3104 ms] /home/nfr/.gnupg/S.gpg-agent.extra
[3104 ms] 
[3104 ms] Start: Run in container: gpgconf --list-dir agent-socket
[3106 ms] /home/matlab/.gnupg/S.gpg-agent
[3106 ms] 
[3106 ms] Start: Run in container: gpgconf --list-dir homedir
[3109 ms] /home/matlab/.gnupg
[3109 ms] 
[3109 ms] Start: Run in container: ls '/home/matlab/.gnupg/private-keys-v1.d' 2>/dev/null
[3112 ms] 
[3112 ms] 
[3112 ms] Exit code 2
[3112 ms] Start: Run in container: mkdir -p -m 700 '/home/matlab/.gnupg'
[3112 ms] Start: Run in Host: docker exec -i -u matlab f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 /bin/sh
[3112 ms] userEnvProbe: loginInteractiveShell (default)
[3113 ms] userEnvProbe shell: /bin/bash
[3117 ms] Start: Run in container: echo ~
[3117 ms] 
[3117 ms] 
[3118 ms] Start: Run in Host: gpgconf --list-dir homedir
[3121 ms] Start: Run in container: # Test for /home/matlab/.ssh/known_hosts and ssh
[3122 ms] /home/nfr/.gnupg
[3122 ms] 
[3124 ms] ssh not found
[3124 ms] 
[3124 ms] Exit code 1
[3124 ms] Start: Run in container: gpgconf --list-dir homedir
[3126 ms] /home/matlab/.gnupg
[3126 ms] 
[3130 ms] Start: Run in container: # Test for /home/matlab/.gnupg/pubring.kbx and gpg
[3132 ms] /home/matlab/.gnupg/pubring.kbx exists
[3132 ms] 
[3132 ms] Exit code 1
[3138 ms] Start: Run in container: # Test for /home/matlab/.gnupg/trustdb.gpg and gpg
[3139 ms] /home/matlab/.gnupg/trustdb.gpg exists
[3140 ms] 
[3140 ms] Exit code 1
[3140 ms] Start: Run in Host: gpg-connect-agent updatestartuptty /bye
[3335 ms] 
[3336 ms] 
[3336 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --system --replace-all credential.helper '!f() { /home/matlab/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /tmp/vscode-remote-containers-7e3c21afde7bf776327103b55e404cfd512793a1.js $*; }; f' || true
[3338 ms] 
[3338 ms] 
[3338 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd ; readlink /proc/$pid/ns/mnt ; cat /proc/$pid/stat | tr "
[3438 ms] Start: Run in container: cat '/home/matlab/.vscode-server/data/Machine/.connection-token-97dec172d3256f8ca4bfb2143f3f76b503ca0534' 2>/dev/null || (umask 377 && echo '5df33980-4081-45c7-9361-0c7f6a8241aa' >'/home/matlab/.vscode-server/data/Machine/.connection-token-97dec172d3256f8ca4bfb2143f3f76b503ca0534-ab6b1dfc-72d3-4130-9413-a01e8e3987b4' && mv -n '/home/matlab/.vscode-server/data/Machine/.connection-token-97dec172d3256f8ca4bfb2143f3f76b503ca0534-ab6b1dfc-72d3-4130-9413-a01e8e3987b4' '/home/matlab/.vscode-server/data/Machine/.connection-token-97dec172d3256f8ca4bfb2143f3f76b503ca0534' && rm -f '/home/matlab/.vscode-server/data/Machine/.connection-token-97dec172d3256f8ca4bfb2143f3f76b503ca0534-ab6b1dfc-72d3-4130-9413-a01e8e3987b4' && cat '/home/matlab/.vscode-server/data/Machine/.connection-token-97dec172d3256f8ca4bfb2143f3f76b503ca0534')
[3441 ms] 630bce77-20c6-4747-b593-ea1a7959d268
[3441 ms] 
[3441 ms] Start: Starting VS Code Server
[3441 ms] Start: Preparing Extensions
[3442 ms] Start: Run in container: test ! -f '/home/matlab/.vscode-server/data/Machine/.installExtensionsMarker' && set -o noclobber && mkdir -p '/home/matlab/.vscode-server/data/Machine' && { > '/home/matlab/.vscode-server/data/Machine/.installExtensionsMarker' ; } 2> /dev/null
[3443 ms] 
[3443 ms] 
[3444 ms] Exit code 1
[3445 ms] Extensions cache, install extensions: None
[3445 ms] Start: Run in container: test -d /home/matlab/.vscode-server/extensionsCache && ls /home/matlab/.vscode-server/extensionsCache || true
[3447 ms] 
[3447 ms] 
[3447 ms] Start: Run in container: test -d /vscode/vscode-server/extensionsCache && ls /vscode/vscode-server/extensionsCache || true
[3449 ms] 
[3449 ms] 
[3449 ms] Extensions cache, link in container: None
[3450 ms] Start: Run in Host: docker exec -i -u matlab -e SHELL=/bin/bash -e VSCODE_AGENT_FOLDER=/home/matlab/.vscode-server -w /home/matlab/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534 f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 /home/matlab/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/bin/code-server --log debug --force-disable-user-env --server-data-dir /home/matlab/.vscode-server --use-host-proxy --telemetry-level all --accept-server-license-terms --host 127.0.0.1 --port 0 --connection-token-file /home/matlab/.vscode-server/data/Machine/.connection-token-97dec172d3256f8ca4bfb2143f3f76b503ca0534 --extensions-download-dir /home/matlab/.vscode-server/extensionsCache --start-server --disable-websocket-compression
[3450 ms] /home/matlab
[3450 ms] 
[3450 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-7e3c21afde7bf776327103b55e404cfd512793a1.js' >/tmp/vscode-remote-containers-7e3c21afde7bf776327103b55e404cfd512793a1.js
[3454 ms] 
[3454 ms] 
[3454 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-server-7e3c21afde7bf776327103b55e404cfd512793a1.js' >/tmp/vscode-remote-containers-server-7e3c21afde7bf776327103b55e404cfd512793a1.js_1675144616792
[3458 ms] 
[3458 ms] 
[3515 ms] userEnvProbe PATHs:
Probe:     '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
Container: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
[3601 ms] *
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*
[3605 ms] Server bound to 127.0.0.1:46777 (IPv4)
Extension host agent listening on 46777

[3605 ms] Start: Run in container: echo 46777 >'/home/matlab/.vscode-server/data/Machine/.devport-97dec172d3256f8ca4bfb2143f3f76b503ca0534'
[3607 ms] 
[3607 ms] 
[3608 ms] Port forwarding for container port 46777 starts listening on local port.
[3609 ms] Port forwarding local port 46777 to container port 46777
[3616 ms] Port forwarding connection from 59142 > 46777 > 46777 in the container.
[3617 ms] Start: Run in Host: docker exec -i -u matlab -e VSCODE_REMOTE_CONTAINERS_SESSION=eeb8c827-e07d-4f71-8548-61e8b590dc591675144612810 f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 /home/matlab/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node -e 
[3617 ms] Start: Run in container: # Test for /home/matlab/.gitconfig and git
[3621 ms] git not found
[3621 ms] 
[3621 ms] Exit code 1
[3625 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --global --replace-all credential.helper '!f() { /home/matlab/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /tmp/vscode-remote-containers-7e3c21afde7bf776327103b55e404cfd512793a1.js $*; }; f' || true
[3627 ms] 
[3627 ms] 
[3631 ms] Start: Run in Host: /home/nfr/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js run-user-commands --workspace-folder /opt/local/github.autonomica/matlab-devcontainer --id-label devcontainer.local_folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer --container-id f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 --log-level debug --log-format json --config /opt/local/github.autonomica/matlab-devcontainer/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --skip-non-blocking-commands false --prebuild false --stop-for-personalization false --remote-env SSH_AUTH_SOCK=/tmp/vscode-ssh-auth-7e3c21afde7bf776327103b55e404cfd512793a1.sock --remote-env REMOTE_CONTAINERS_IPC=/tmp/vscode-remote-containers-ipc-7e3c21afde7bf776327103b55e404cfd512793a1.sock --remote-env REMOTE_CONTAINERS=true --mount-workspace-git-root true --terminal-columns 71 --terminal-rows 13
[3785 ms] [05:56:57] Extension host agent started.
[3805 ms] (node:27893) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[3805 ms] (Use `node --trace-deprecation ...` to show where the warning was created)
[3808 ms] @devcontainers/cli 0.25.2. Node.js v16.14.2. linux 5.10.102.1-microsoft-standard-WSL2 x64.
[3808 ms] Start: Run: docker buildx version
[3815 ms] Port forwarding 59142 > 46777 > 46777 stderr: Connection established
[3817 ms] [05:56:57] ComputeTargetPlatform: linux-x64
[3835 ms] Port forwarding connection from 59143 > 46777 > 46777 in the container.
[3835 ms] Start: Run in Host: docker exec -i -u matlab -e VSCODE_REMOTE_CONTAINERS_SESSION=eeb8c827-e07d-4f71-8548-61e8b590dc591675144612810 f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 /home/matlab/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node -e 
[3840 ms] [05:56:57] [127.0.0.1][657b9fac][ManagementConnection] New connection established.
[3966 ms] github.com/docker/buildx v0.9.1 ed00243a0ce2a0aee75311b06e32d33b44729689
[3966 ms] 
[3969 ms] Start: Run: git rev-parse --show-cdup
[3974 ms] Start: Run: docker inspect --type container f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6
[4013 ms] Port forwarding 59143 > 46777 > 46777 stderr: Connection established
[4061 ms] Start: Inspecting container
[4062 ms] Start: Run: docker inspect --type container f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6
[4143 ms] Start: Run in container: /bin/sh
[4146 ms] Start: Run in container: uname -m
[4310 ms] x86_64
[4310 ms] 
[4310 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[4312 ms] NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[4312 ms] 
[4312 ms] Start: Run in container: cat /etc/passwd
[4315 ms] userEnvProbe: loginInteractiveShell (default)
[4315 ms] Start: Run in container: mkdir -p '/home/matlab/.devcontainer' && CONTENT="$(cat '/home/matlab/.devcontainer/.onCreateCommandMarker' 2>/dev/null || echo ENOENT)" && [ "${CONTENT:-2023-01-31T05:45:11.027498924Z}" != '2023-01-31T05:45:11.027498924Z' ] && echo '2023-01-31T05:45:11.027498924Z' > '/home/matlab/.devcontainer/.onCreateCommandMarker'
[4316 ms] userEnvProbe shell: /bin/bash
[4316 ms] Start: Run in container: /bin/bash -lic echo -n 123c68cb11d063061740a62e7cfc4d3a; cat /proc/self/environ; echo -n 123c68cb11d063061740a62e7cfc4d3a
[4319 ms] 
[4319 ms] 
[4319 ms] Exit code 1
[4320 ms] Start: Run in container: mkdir -p '/home/matlab/.devcontainer' && CONTENT="$(cat '/home/matlab/.devcontainer/.updateContentCommandMarker' 2>/dev/null || echo ENOENT)" && [ "${CONTENT:-2023-01-31T05:45:11.027498924Z}" != '2023-01-31T05:45:11.027498924Z' ] && echo '2023-01-31T05:45:11.027498924Z' > '/home/matlab/.devcontainer/.updateContentCommandMarker'
[4323 ms] 
[4323 ms] 
[4323 ms] Exit code 1
[4323 ms] Start: Run in container: mkdir -p '/home/matlab/.devcontainer' && CONTENT="$(cat '/home/matlab/.devcontainer/.postCreateCommandMarker' 2>/dev/null || echo ENOENT)" && [ "${CONTENT:-2023-01-31T05:45:11.027498924Z}" != '2023-01-31T05:45:11.027498924Z' ] && echo '2023-01-31T05:45:11.027498924Z' > '/home/matlab/.devcontainer/.postCreateCommandMarker'
[4327 ms] 
[4327 ms] 
[4327 ms] Exit code 1
[4327 ms] Start: Run in container: mkdir -p '/home/matlab/.devcontainer' && CONTENT="$(cat '/home/matlab/.devcontainer/.postStartCommandMarker' 2>/dev/null || echo ENOENT)" && [ "${CONTENT:-2023-01-31T05:56:55.098069686Z}" != '2023-01-31T05:56:55.098069686Z' ] && echo '2023-01-31T05:56:55.098069686Z' > '/home/matlab/.devcontainer/.postStartCommandMarker'
[4330 ms] 
[4330 ms] 
Running the postStartCommand from devcontainer.json...

[4336 ms] [05:56:57] [127.0.0.1][1750b1b2][ExtensionHostConnection] New connection established.
[4341 ms] [05:56:57] [127.0.0.1][1750b1b2][ExtensionHostConnection] <262> Launched Extension Host Process.
[4458 ms] userEnvProbe PATHs:
Probe:     '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
Container: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
[4458 ms] Start: Run in container: /bin/sh -c -browser
/bin/sh: 0: Illegal option -r
[4706 ms] postStartCommand failed with exit code 2. Skipping any further user-provided commands.
[4707 ms] Error: Command failed: /bin/sh -c -browser
[4707 ms]     at HL (/home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:1691:137)
[4708 ms]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[4708 ms]     at async Promise.all (index 0)
[4708 ms]     at async qL (/home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:1683:3748)
[4708 ms]     at async Wg (/home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:1683:2951)
[4708 ms]     at async mue (/home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:2020:27351)
[4708 ms]     at async pue (/home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js:2020:25040)
[4712 ms] Exit code 1
[4713 ms] Command failed: /home/nfr/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534/node /home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.266.1/dist/spec-node/devContainersSpecCLI.js run-user-commands --workspace-folder /opt/local/github.autonomica/matlab-devcontainer --id-label devcontainer.local_folder=\\wsl$\Ubuntu-20.04\opt\local\github.autonomica\matlab-devcontainer --container-id f99f7d01bcb0be5b51891e682d6b55ab6f9ab8f636aae12a025ffe3c7496a3a6 --log-level debug --log-format json --config /opt/local/github.autonomica/matlab-devcontainer/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --skip-non-blocking-commands false --prebuild false --stop-for-personalization false --remote-env SSH_AUTH_SOCK=/tmp/vscode-ssh-auth-7e3c21afde7bf776327103b55e404cfd512793a1.sock --remote-env REMOTE_CONTAINERS_IPC=/tmp/vscode-remote-containers-ipc-7e3c21afde7bf776327103b55e404cfd512793a1.sock --remote-env REMOTE_CONTAINERS=true --mount-workspace-git-root true --terminal-columns 71 --terminal-rows 13

It would be really nice if the Matlab image could run as a DevContainer.

prabhakk-mw commented 1 year ago

hi @NicolasRouquette

The -browser flag is an option meant for the ENTRYPOINT to the mathworks/matlab container and is not a valid startup flag to the matlab process it self.

The ENTRYPOINT for the mathworks/matlab:r2022b container should be calling a script run.sh we've written to support the various flags. run.sh will already be on the PATH inside the container and you should be able to add it to your postStartCommand as ./run.sh -browser

Could you give this a shot? In the meantime, I'll try to configure an environment on my end to try this as well.

prabhakk-mw commented 3 months ago

hi @NicolasRouquette mathworks-ref-arch/matlab-codespaces has been released with various .devcontainer configurations to showcasing usage of DevContainers.

Please have a look at that repository and create an issue on that repository if there are any additional feature requests or suggestions.

Thank you!

fixed by https://github.com/mathworks-ref-arch/matlab-codespaces/commit/ddd5406