Featured image of post Develop Applications on Debian using VSCode and Dev Containers

Develop Applications on Debian using VSCode and Dev Containers

A guide on how to use Docker, VSCode and Dev Containers on Debian to develop applications.

Installing Visual Studio Code on Debian

Update Package List for VSCode

Before installing any new software, it’s a good practice to update the package list.

sudo apt update

Download VSCode

Download the latest version of Visual Studio Code from the official link or use wget to download it directly.

wget -O vscode.deb https://go.microsoft.com/fwlink/?LinkID=760868

To use apt to install the downloaded package.

sudo apt install ./vscode.deb

This will install the .deb package along with all of its dependencies if there are any.

Installing the .deb package will automatically install the apt repository and signing key to enable auto-updating using the system’s package manager.

Install VSCode with dpkg

To use dpkg to install the downloaded package.

sudo dpkg -i vscode.deb

If any dependencies are missing, you can run:

sudo apt install -f

Installing the .deb package will automatically install the apt repository and signing key to enable auto-updating using the system’s package manager.

Installing Docker on Debian

Update Package List for Docker

Ensure your package list is up-to-date.

sudo apt update

Install Docker Dependencies

sudo apt install apt-transport-https ca-certificates curl gnupg

Create Directory with Permisions

sudo install -m 0755 -d /etc/apt/keyrings

Add Docker GPG Key

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Modify File Permisions

sudo chmod a+r /etc/apt/keyrings/docker.gpg

Add Docker Repository

echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Add user to the Docker group

To be able to use Dev Containers within VSCode we need to add our user to the docker group.

sudo usermod -aG docker username

Adding the Dev Container Extension to VSCode

Open VSCode

Launch Visual Studio Code with your application launcher or the following:

code

Install Dev Container Extension

Navigate to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing Ctrl + Shift + X. Search for “Dev Containers” and install it.

Reload VSCode

After installation, reload VSCode to activate the extension.

Open Project in Container

In VSCode you’ll see a “remote” icon in the bottom-left corner prompting you to open a remote window. Click on it, click on “New Dev Container…” and search for your programming language or framework and follow the instructions.

Now you’re all set! Your development environment is isolated within a Docker container, making it easy to share and replicate across different systems. Happy coding! 🚀

Image by pressfoto on Freepik

Built with Hugo
Theme Stack designed by Jimmy