Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Remote Container - extensions not installing on dev container using docker-compose

I am having trouble getting extensions installed in the dev container using "Remote - Containers". I do not know if it's a bug, incorrect configuration on my end, or intended behaviour. Down below is my current configuration, both files are located in the root folder of the project.

docker-compose.yml

version: "3.7"

services:
  api:
    image: node:12
    restart: always
    ports:
      - ${API_PORT}:3000
    volumes:
      - .:/usr/app
      - /usr/app/node_modules
    working_dir: /usr/app
    command: bash -c "yarn && yarn dev"

.devcontainer.json

{
    "dockerComposeFile": "docker-compose.yml",
    "service": "api",
    "workspaceFolder": "/usr/app",
    "extensions": [
        "eamodio.gitlens",
        "formulahendry.auto-rename-tag",
        "coenraads.bracket-pair-colorizer-2",
        "kumar-harsh.graphql-for-vscode",
        "esbenp.prettier-vscode",
        "ms-vscode.vscode-typescript-tslint-plugin",
        "visualstudioexptteam.vscodeintellicode"
    ]
}

The list of extensions listed in the .devontainer.json are the ones I want to have installed in the dev container. Any help is appreciated!

like image 593
rosengrenen Avatar asked May 05 '19 13:05

rosengrenen


People also ask

How do I connect to remote Docker container VS Code?

To attach to a Docker container, either select Remote-Containers: Attach to Running Container... from the Command Palette (F1) or use the Remote Explorer in the Activity Bar and from the Containers view, select the Attach to Container inline action on the container you want to connect to.

How do I manually install downloaded Extensions in VS Code?

You can manually install a VS Code extension packaged in a . vsix file. Using the Install from VSIX command in the Extensions view command dropdown, or the Extensions: Install from VSIX command in the Command Palette, point to the . vsix file.

How do I run a Docker compose file in Visual Studio code?

You can then use the Docker Compose Up command (right-click on the docker-compose. yml file, or find the command in the Command Palette) to get everything started at once. You can also use the docker-compose up command from the command prompt or terminal window in VS Code to start the containers.

How do I enable Extensions in VS Code?

Find extensions to install using the Extensions view. Install an extension from the VS Code Extension Marketplace. See what features are added via the Features Contributions tab or Command Palette (Ctrl+Shift+P). See recommendations for other extensions.


1 Answers

According to the Visual Studio Code documentation, the two files need to be located in a directory .devcontainer in the workspace root.

I still had issues installing the extensions while working from behind a corporate proxy. The solution was to give the container access to the proxy server:

If you use an authenticating proxy like Cntlm on your local machine, configure it to listen on 172.17.0.1 (the Docker interface). Then define the http_proxy and https_proxy environment variables for the container. For example, in devcontainer.json:

"containerEnv": { 
  "http_proxy": "http://172.17.0.1:3128",
  "https_proxy": "http://172.17.0.1:3128"
}

Or in docker-compose.yaml

services:
  devcontainer:
    environment:
      http_proxy: http://172.17.0.1:3128
      https_proxy: http://172.17.0.1:3128

Or configure docker-compose.yaml to make the container use the host network:

services:
  devcontainer:
    network_mode: host

Then you can just pass the same proxy variables into the container as used on the host. For example, in the docker-compose.yaml:

services:
  devcontainer:
    environment:
      http_proxy: $http_proxy
      https_proxy: $https_proxy

If you are not using a local, but rather a remote proxy inside of your network, you can do the latter regardless of the container's network configuration (host or default).

like image 183
clssn Avatar answered Sep 22 '22 14:09

clssn