Developing remotely inside a docker container¶
Overview
This guide covers a possible procedure to develop your software on the device inside the docker engine.
Prerequisites
- Docker Engine set up and running on the device
- VS Code with Remote Development extension pack installed (including a compatible SSH Client) Remote Development extension pack documentation
Prepare development container¶
In this example we are preparing a container for Node.JS development. The process should be similar for other development environments.
- Login to Portainer
- Click on Home and then on Local
- Click on Volumes
-
Add a new volume
-
Click on Containers
- Add a new container. Map port 22 to a valid port on the host (must be in the range from 49152 to 65535). Map the volume to the work folder. Set Console to Interactive & TTY.
- Wait for the container to be deployed.
- Click on Exec Console on the newly created container
-
Click on Connect
-
Run the following commands and define new password in the last command.
apt update
apt install openssh-server curl -y
systemctl enable ssh
service ssh start
useradd -rm -d /home/dev -s /bin/bash -g root -G sudo dev
chown dev: /work
passwd dev
Connect to the container with VS Code¶
- Open Remote Explorer in VS Code and click on the + symbol.
- Enter connection string. Tweak the hostname and port accordingly.
- Confirm configuration location with enter.
- Click on the Connect to Host in new Window button on the created target.
- Confirm fingerprint.
- Enter password when prompted and wait for the connection.
- Click on Open Folder and choose /work/
You are now ready to start developing your application as if you were working on your local machine but everything will be executed and saved directly on the device.