[November 2020 version] Connect DevContainer of Dockerfile to Docker network [VSCode]

I want to connect the DevContainer defined in the Dockerfile to the existing Docker network

Add the following settings to .devcontainer.json and it's OK.

json:.devcontainer.json


...
"runArgs": [ "--network=other-docker-network"] 
...

that's all.

By the way, the available docker network names can be listed with docker network ls.

reference

https://code.visualstudio.com/docs/remote/devcontainerjson-reference https://docs.docker.com/engine/reference/commandline/run/ https://docs.docker.com/network/

Commentary

In VS Code's DevContainer, it can also be defined with docker-compose, but there are some problems if you want to do Docker-compose on a remote Docker server. If you want to develop DB, Redis, Nginx, etc. in separate containers, it is often the case. It is natural to say that you want to use docker-compose, and there is no problem with using docker-compose locally. Docker can also connect to the server in the form ssh: // docker @ docker-server, but doing this with Dokcer-compose causes problems.

https://github.com/docker/compose/issues/6336 "Docker Compose doesn't work when SSH connection used to remote Docker Engine"

This issue is an SSH connection to dokcer-py, which is the core of docker-compose. [Paramiko] to use (https://github.com/paramiko/paramiko) Does compose and docker-py have any trouble because the library doesn't read AuthorizedKeys? It seems that it is. .. ..

For now, is there only local if you want to use docker-compose ...?

In addition, the following page will be helpful for settings such as connecting to a remote docker host with VS Code in the first place.

-Use VS Code DevContainer for ssh connection such as VM

Recommended Posts

[November 2020 version] Connect DevContainer of Dockerfile to Docker network [VSCode]
I tried to build the environment of WSL2 + Docker + VSCode
[Docker Network Chapter 1] Explanation of Docker Networking
Introduced vscode with apt to docker: ubuntu
Introduced Docker to Windows 10 Home August 2020 version