Install Visual Studio Code Server Inside Docker Container in Linux

Install Visual Studio Code Server Inside Docker Container in Linux

Visual Studio Code (VS Code) is a source code editor that can be used with various programming languages. Visual Studio Code Server (VS Code Server) allows accessing VS Code through web browser.

This tutorial explains how to install VS Code Server inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install VS Code Server

  • Host network

Run the following command to create a container for VS Code Server that uses host network:

docker run -d --name=vscode --restart=always --network=host \
    -v /opt/vscode/workspace:/config/workspace \
    -e PASSWORD=pwd123 \
    -e SUDO_PASSWORD=pwd123 \
    linuxserver/code-server
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, VS Code service is listening on port 8443. It can be changed with -p option.

docker network create app-net
docker run -d --name=vscode --restart=always --network=app-net \
    -p 8080:8443 \
    -v /opt/vscode/workspace:/config/workspace \
    -e PASSWORD=pwd123 \
    -e SUDO_PASSWORD=pwd123 \
    linuxserver/code-server

Note: don't forget to change web interface password and sudo password, which is used in the VS Code terminal.

Testing VS Code Server

Open a web browser and go to http://<IP_ADDRESS>:8443, where <IP_ADDRESS> is the IP address of the system. Log in to the web interface using password.

Visual Studio Code Server Inside Docker Container in Linux

Uninstall VS Code Server

To completely remove VS Code Server, remove its container:

docker rm --force vscode

Remove VS Code Server image:

docker rmi linuxserver/code-server

You can also remove VS Code workspace:

sudo rm -rf /opt/vscode

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.