Difference between revisions of "Containers 2026"

From Wiki at Neela Nurseries
Jump to navigation Jump to search
m (Install missing deps after container creation)
m (WorkspaceMount and workspaceFolder options)
Line 93: Line 93:
  
 
$ npm install -g @devcontainers/cli
 
$ npm install -g @devcontainers/cli
 +
 +
WorkspaceMount and workspaceFolder options:
 +
 +
*  https://stackoverflow.com/questions/77293917/how-to-mount-source-code-in-a-devcontainer-at-build-time
 +
 +
 +
 +
 +
  
 
<!--
 
<!--

Revision as of 07:14, 27 January 2026

Note on Devcontainers

Found this first:

(1) https://www.docker.com/blog/streamlining-local-development-with-dev-containers-and-testcontainers-cloud/

Followed only the install step of these steps . . . this article seems to be talking about some software called "Zephyr" which is unrelated to Zephyr RTOS Project:

(2) https://docs.docker.com/engine/install/ubuntu/s

Mention here of `compose.yml`:

(3) https://embedded-house.ghost.io/zephyr-with-dev-containers/

Goliath company post on devcontainers:

(4) https://blog.golioth.io/build-before-installing-zephyr-dev-environment-using-codespaces/

An example .devcontainer file here but article is Java specific an talks a lot about a Java project.

(5) https://medium.com/versent-tech-blog/introduction-to-dev-containers-4c01cb1752a0

Best article yet, more general but good explanation:

(6) https://containers.dev/guide/dockerfile

A github project with example `devcontainer.json` and `docker-compose.yml`:

(7) https://forge.hefr.ch/serge.ayer/zephyr-dev-devcontainer/-/blob/main/.devcontainer/docker-compose.yml?ref_type=heads

ZephyrRTOS-Project docker image repo:

(8) https://github.com/zephyrproject-rtos/docker-image


Post commands support:


First Docker compose based container set up:

Notes about devcontainer start up script elements

To build on localhost using the Docker composed container, a start up script cam be written in the Zephyr or other local copy of a project, to check for and to invoke `devcontainer` with necessary arguments.

Such a script will likely first assure that it is running from the same directory as where the `.devcontainer` folder lives, if it is not already there. The scripts may then:

[ ] check that `devcontainer` is installed by trying to call it (shell built-in `command` may be helpful with this test) [ ] assure that a `docker_cache` directory exists in the project root dir

   (create `./docker_cache` if not found)

[ ] check whether the container is running and if not start it (see note 1) [ ] check whether any project specific container config is complete

Notes: (1) The checks for "container running" and "config complete" can be combined into a single function. This reflects the fact that we likely only want to run the container and have our container start helper script report success when the container is fully configured for the given project.

Other functions in the helper script call `devcontainer` with tokens which start with its `exec` option. In a shell script, this `exec` option is usually followed by a double quoted string to express the commands we would issue at a command shell. For example, commands to build the app, to build menuconfig, to execute tests, and related things.

devcontainer exec uses

Stuart Leeks help document on devcontainer exec use:

@devcontainers/cli

Important to stall the following Python scripts mentioned here:

Command is:

$ npm install -g @devcontainers/cli

WorkspaceMount and workspaceFolder options: