SSH + Dev Containers¶
Using SSH is a command-line-driven method for setting up your local development environment. This method is great for those who are comfortable with the command line and want to use emacs, for example, as their editor. This method is a little more advanced and might require some additional setup.
dev container + docker settings¶
- Ensure the
sshd
feature is enabled in the dev container. - Port forward the
sshd
port to your local machine in the docker-compose.yml - Mount your authorized keys into the dev container in the docker-compose.yml
- Ensure
~/.ssh
is owned by thevscode
user in the Dockerfile.
Manually setting up SSH agent forwarding¶
The provided dev container listens for SSH connections on port 2222 and bind mounts ~/.ssh/authorized_keys
from the host to facilitate SSH. In order to perform Git operations (i.e., committing code in the container), you will need to enable SSH agent forwarding from your machine to the dev container. While VS Code handles this automatically, for other editors you will need to set this up manually.
To do so, update your ~/.ssh/config
to support agent forwarding. The following config snippet should accomplish this for you:
Now to connect to the dev container, you can use the following command:
Additional setup¶
The goal of this project is to use dev containers
as the primary environment for local development. There are several examples using vim
and several of its variants, along with emacs
. This is considered the advanced approach to local development, and your mileage may vary. It's expected that you would need to modify these examples to suit your needs.
Created: 2023-08-31