Docker setupΒΆ

You can use Docker to run test IOCs that are convenient for testing without having to locally build and install EPICS IOCs. Please use the following Docker links to install and configure Docker:

To communicate with the Docker you have set up some environmental variables:

#!/bin/bash

export DOCKER0_IP="172.17.0.1"
export EPICS_CA_ADDR_LIST=$( echo $DOCKER0_IP | sed -e 's/^\([0-9]\+\)\.\([0-9]\+\)\..*$/\1.\2.255.255/' )
export EPICS_CA_AUTO_ADDR_LIST="no"
export EPICS_CA_MAX_ARRAY_BYTES=10000000

and to run docker with the correct images (assuming the preceding code block is saved in epics_exports.sh):

#!/bin/bash

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $SCRIPTS_DIR/epics_exports.sh

MOTOR_DOCKERIMAGE="nsls2/epics-docker:latest"
PE_DOCKERIMAGE="nsls2/pyepics-docker:latest"
AD_DOCKERIMAGE="prjemian/synapps-6.1-ad-3.7:latest"

docker pull ${MOTOR_DOCKERIMAGE}
docker pull ${PE_DOCKERIMAGE}
docker pull ${AD_DOCKERIMAGE}

mkdir -p /tmp/ophyd_AD_test/

# Create YYYY/MM/DD subdirectories.
# This is required because the images use a version of AD which
# does not create missing directories.
python $SCRIPTS_DIR/create_directories.py /tmp/ophyd_AD_test/data1

docker run --rm -d -v /tmp/ophyd_AD_test:/tmp/ophyd_AD_test/ ${MOTOR_DOCKERIMAGE}
docker run --name=area-detector --rm -dit -v /tmp/ophyd_AD_test:/tmp/ophyd_AD_test/ -e AD_PREFIX="ADSIM:" ${AD_DOCKERIMAGE} /bin/bash
sleep 1  # Probably not needed?
docker exec area-detector iocSimDetector/simDetector.sh start
docker run --rm -d ${PE_DOCKERIMAGE}

Running this multiple times will lead to multiple instances of the images running.

For EPICS to know where to search for the IOCs you will need to do

source epics_exports.sh

to setup the EPICS environmental variables. To check that it is setup correctly

$ env | grep -i epics
EPICS_CA_ADDR_LIST=172.17.255.255
EPICS_CA_AUTO_ADDR_LIST=no
EPICS_CA_MAX_ARRAY_BYTES=10000000

To check if it is working, try

$ caget XF:31IDA-OP{Tbl-Ax:X1}Mtr

Note

You may need to install pyepics, which installs epics-base and the corresponding caget executable:

conda install -c lightsource2-tag pyepics