Many times I want a throw-away implementation of a system I am working on. Something that allows me to quickly develop an idea, try a theory, or make a quick test of some code. A good solution to problems like this is to use Docker to launch a container that already has the system of interest built and ready to go.
So I set about building a Docker container that would provide a Linux environment with a full EPICS installation.
I’ve put the container on Docker Hub, so it’s simple for others to use. If you want to run this you will need Docker already installed. Then execute the following from a command-line (this works on Mac and Linux — I have no idea how it would be done on Windows 🙁 ):
docker run -t -i sdmolloy/ubuntu-playground /bin/bash
This will download the appropriate files from Docker Hub, start the container running, and drop you into a bash prompt as the root user. You probably shouldn’t run stuff as root, so I included a regular user account:
- Username — pi
- Password — pi
Not very imaginative, but security is rarely my chief concern when developing these throw-away containerized services.
Change to this user:
su - pi
You should now have access to the full range of EPICS abilities.
Once you have developed your database, and started it running, you will probably want to go to a different terminal to run caget, caput, etc., commands. You can do this by running the EPICS database with screen, but an alternative to this is to connect to the container from another terminal. To do this, type the following:
docker exec -it $(docker ps -aq) /bin/bash
This assumes that you only have one docker container running. If not, you will have to use the following command to figure out the ID of the container you are interested in:
If you want the details of what is going on behind the scenes, check out GitHub:
I never intended this to be a replacement for a regular EPICS installation. Rather, this is a playground that gives you somewhere to experiment and test ideas, or to allow you to demonstrate EPICS to students.
Docker containers are very “closed” in terms of their integration with the network. Primarily this means that you will not be able to view containerized PV’s from the host machine. If this were intended to be a full EPICS solution, this fact alone would be fatal, but the playground nature of this means that this is not an issue. This lack of network access will also result in a CA_BEACON error message, but it turns out that this is not critical. The EPICS installation will still work correctly within the container.
I had believed that an EPICS IOC in such a Docker container could not be seen from outside, but I have since learnt that running the container with the right command can fix this.
docker run -p 5064:5064 -p 5065:5065 -p 5064:5064/udp -p 5065:5065/udp -t -i --rm sdmolloy/ubuntu-playground:latest /bin/bash
Docker containers don’t integrate very well with the host’s graphical environment. In this case, that means that it won’t be possible to test CS Studio or other graphical EPICS-related tools.