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
.
https://code.visualstudio.com/docs/remote/devcontainerjson-reference https://docs.docker.com/engine/reference/commandline/run/ https://docs.docker.com/network/
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.
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