Skip to content

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

Prepare development container

In this example we are preparing a container for Node.JS development. The process should be similar for other development environments.

  1. Login to Portainer
  2. Click on Home and then on Local
  3. Click on Volumes
  4. Add a new volume Create Volume

  5. Click on Containers

  6. 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.

Create Container

Map Volume

Console Settings

  1. Wait for the container to be deployed.
  2. Click on Exec Console on the newly created container
  3. Click on Connect Connect to Console

  4. 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

  1. Open Remote Explorer in VS Code and click on the + symbol.
  2. Enter connection string. Tweak the hostname and port accordingly.

Connection String

  1. Confirm configuration location with enter.
  2. Click on the Connect to Host in new Window button on the created target.

Connect to

  1. Confirm fingerprint.

Fingerprint

  1. Enter password when prompted and wait for the connection.
  2. Click on Open Folder and choose /work/

Open Folder

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.