How to install VS Code extensions using code-server?

1.5k Views Asked by At

Here's my Dockerfile:

FROM linuxserver/code-server:latest

[..]

As you can see, I'm using an image that has code-server installed. and it works just fine. When I run it, I can see VS Code via localhost:8443.

However, when I try to install VS Code extensions there, I receive errors (such as HTTP 403 errors).

How can I fix it?

2

There are 2 best solutions below

0
On

It needs to be done sequentially in bash, e.g. using a loop or equivalents.

A simple loop example:

RUN EXT_LIST="ms-toolsai.jupyter ms-python.python" && \
    for EXT in $EXT_LIST; do code-server --install-extension $EXT; done

The need for such looping is due to a recent change in code-server, which no longer accepts multiple arguments passed to a single --install-extension argument (which used to accept space-delimited lists at least until v4.9.1).

Be cautious with xargs though, as it seems to process only the 1st array element when executed as part of a RUN command in a Dockerfile.

0
On

Try this.

RUN /app/code-server/bin/code-server \
    --install-extension EXTENSION_ID_1 \
    --install-extension EXTENSION_ID_2 \
    --install-extension EXTENSION_ID_3 \
    --extensions-dir /config/extensions