Troubleshooting#

Running Multiple IOCs in DevContainers on one Workstation#

If you want to test two or more IOCs on a workstation, you can launch two developer containers and run an IOC instance in each.

However, the auto port forwarding will not be able to bind to the default ports for the second container. It will therefore pick a different port number to bind to on the host. Inside of the container the IOC will still be listening on the default ports, but on the host the ports will be different. For example here is the PORTS tab of vscode when I have launched a second IOC on my workstation:

../_images/auto-ports2.png

Port Forwarding in the bottom panel of VSCode#

You will be able to interact with each of these IOCs as usual inside the container but what if you want to connect to both of them from outside the container? This can be done by adding the list of ports to the appropriate environment variables. For example:

export EPICS_CA_NAME_SERVERS="127.0.0.1:5064 127.0.0.1:5065"
export EPICS_PVA_NAME_SERVERS="127.0.0.1:5075 127.0.0.1:5076"

The equivalent settings in phoebus’ settings.ini file would be:

org.phoebus.pv.ca/name_servers=127.0.0.1:5064 127.0.0.1:5065
org.phoebus.pv.pva/epics_pva_name_servers=127.0.0.1:5075 127.0.0.1:5076

Unable to contact IOC PVs from outside the developer container#

Note that sometimes you may get a zombie process holding on to your host’s Channel Access ports. In this case when you start an IOC in devcontainer it will not bind to those ports as they are already in use. You just need to go to the PORTS tab and see which ports have been bound to the IOC and then set the environment variables accordingly. See the Running Multiple IOCs in DevContainers on one Workstation section for more information.

Resetting VSCode Cache#

Occasionally if vscode gets stuck in a bad state, you may need to reset the cache.

# close vscode

# make sure there are no stuck vscode processes
pkill code

# remove the vscode caches
rm -rf ~/.vscode/* ~/.vscode-server/*

# restart vscode

Reopen in Container fails: Docker not found#

Problem: on a podman host, VSCode’s Reopen in Container reports that Docker is not installed and offers to install it.

Cause: the Dev Containers extension runs a docker binary by default.

Solution: point the extension at podman by setting dev.containers.dockerPath in your user settings; see the workstation setup guide.

Cleaning up Container Cache#

Very occasionally it may be necessary to reset all of your container cache. You might want to do this if you have filled up your disk or if you just want to get back to a known state.

To remove all container cache on a workstation:

# clean out the podman local cache
podman system reset -f

The above removes:

  • all images

  • all containers including running containers

  • all volumes

  • all networks

If on the other hand you would like to just clear individual containers or images then:

# list all containers including stopped ones
podman ps -a
# use the generated name (last column) to remove some containers
podman rm container_name1 container_name2

# list all images
podman images
# use the image id to remove some images
podman rmi image_id1 image_id2

Permissions issues with GitHub#

Problem: in the devcontainer you see the following error:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Solution: you may need to add your github ssh key to the ssh-agent as follows:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Where id_rsa is the name of your private key file you use for connecting to GitHub.

Pulling a public image from ghcr.io fails with “denied”#

Problem: pulling an epics-containers image or Helm chart fails even though it is public, for example:

Error response from daemon: Head "https://ghcr.io/v2/epics-containers/ioc-adsimdetector-runtime/manifests/2.11ec9": denied: denied

or, from Helm:

Error: could not download oci://ghcr.io/epics-containers/charts/ioc-instance: failed to authorize:
failed to fetch oauth token: unexpected status from GET request to
https://ghcr.io/token?...: 403 Forbidden

Cause: epics-containers images and charts on ghcr.io can be pulled without logging in. If you have stored credentials for ghcr.io and they are no longer valid, for example an expired or deleted GitHub token, the registry rejects the pull instead of falling back to anonymous access.

Solution: remove the stored credentials from every tool that may hold them, then try again:

podman logout ghcr.io
docker logout ghcr.io      # if the docker CLI is installed
helm registry logout ghcr.io

Run all of them, even if you use podman: docker compose sends the credentials stored in ~/.docker/config.json by docker login, so a stale token there survives podman logout. Any of the commands may report that you were not logged in; that is fine.

If you do need to log in, for example to push your own images, use a current personal access token (classic) with the read:packages scope (write:packages to push). Fine-grained tokens are not accepted by GitHub Packages; see Working with the Container registry.

If a pull still fails after logging out, GHCR occasionally returns a transient 403 Forbidden when fetching a token; retry it.

Cannot connect to the container service#

podman is daemonless, but docker compose talks to it through the podman socket. If compose cannot connect, the podman user socket is probably not running — see Podman Integration with Docker Compose for how to enable it and point DOCKER_HOST at it.

(If you are using docker instead of podman, see Using Docker Instead of Podman for docker daemon troubleshooting.)

Template files out of date after copier update#

Problem: .copier-answers.yml reports the latest template _commit, but a template-managed file (for example .pre-commit-config.yaml or renovate.json) still has an old version. No .rej files or conflict markers were left behind.

Cause: copier update applies only the changes between two template versions, so a file that has diverged is not corrected once the template stops changing that file.

Solution: see Checking for Template Drift to detect the drifted files with copier recopy and restore them.

Container storage errors initializing the storage driver#

Solution: The most likely reason is that you are using a filesystem like zfs or btrfs which requires a special storage driver, click link for more information

Error processing a compose file#

Solution: make sure your docker compose is up to date

Disable recursive git-repository scanning in VSCode#

Generic IOC dev containers hold many git repositories under /epics/support (the ibek-support submodule plus support modules). Stop VSCode scanning them all by adding to your user settings (Ctrl-Shift-P -> Preferences: Open User Settings (JSON)):

"scm.alwaysShowRepositories": true,
"git.repositoryScanMaxDepth": 0,
"scm.repositories.visible": 12,

DBD files must be combined in the correct order#

A Generic IOC build fails with an error such as:

dbdExpand.pl: Device 'stream' refers to unknown record type 'scalcout'.
        DBD files must be combined in the correct order.
Context: file '/epics/support/StreamDevice/dbd/stream.dbd'
  while reading 'stream.dbd' to create '../O.Common/oxCryo.dbd.d'
Creating dbd file oxCryo.dbd

Cause: dbdExpand.pl reads DBD files in the order they are listed. A DBD file that uses a record type must come after the DBD file that defines that record type. Here stream.dbd uses the scalcout record, which calcSupport.dbd defines.

Solution: in the support module’s *App/src/Makefile, list each DBD file after the DBD files it depends on. For example, the oxCryo module had:

oxCryo_DBD += base.dbd
oxCryo_DBD += stream.dbd
oxCryo_DBD += asyn.dbd
oxCryo_DBD += calcSupport.dbd
oxCryo_DBD += alarmlookup.dbd

The fix moves calcSupport.dbd before stream.dbd:

oxCryo_DBD += base.dbd
oxCryo_DBD += calcSupport.dbd
oxCryo_DBD += stream.dbd
oxCryo_DBD += asyn.dbd
oxCryo_DBD += alarmlookup.dbd

If the error names the IOC DBD file instead of a support module DBD file, check the order of the ansible.sh lines in the Generic IOC Dockerfile. See Add the module to the Dockerfile.