0

I have a project consisting of a set of Docker Containers with one container running django, a second running NGINX, and a third running a postgres database running as a Dev Container. The project files live in Ubuntu via WSL2 in Windows 10 Pro.

When I make code changes inside the Dev Container the changes are saved to the Dev Container. Changes are preserved when the Dev Container is closed then reopened. Yay!

Next I'd like to push my changes to the local code directories. How is pushing code changes from Dev Container to a local directory performed?

I’m running VS Code and Docker Desktop in Windows 10 Pro. My project files live in Ubuntu via WSL2. \wsl.localhost\Ubuntu-20.04\home\marshall\discov Thus, to start my project in VS Code I cd to the directory in WSL2 CLI, then execute ‘code .’

I have tried changing the workspaceFolder location to point to the directory location in WSL2.
"workspaceFolder": \wsl.localhost\Ubuntu-20.04\home\marshall\discov, ...But this throws the error: Workspace folder in devcontainer.json must be an absolute path

This build (below) works fine: for making live changes in the container… they just aren’t saved to actual files outside of the devcontainer.

My devcontainer.json file: { "name": "My Devcontainer" "dockerComposeFile": "../docker-compose-devcontainer.yml", "service": "django", "workspaceFolder": "/opt/disc",

"customizations": {
    "vscode": {
        // Add the IDs of extensions you want installed when the container is created.
        "extensions": [
            "mtxr.sqltools",
            "mtxr.sqltools-driver-pg",
            "ms-python.python"
        ],
        "settings": {
            "sqltools.connections": [
                {
                    "previewLimit": 50,
                    "server": "172.21.0.2",
                    "port": 5432,
                    "askForPassword": true,
                    "driver": "PostgreSQL",
                    "name": "My Fancy Database",
                    "database": "my-database-name",
                    "username": "my-database-username",
                    "connectionTimeout": 5000
                  }
            ]

        }
    }
}
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
    10080, 10032, 8000, 80, 443, 5432
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"

}

Matt
  • 1
  • 1

0 Answers0