Skip to content

Working with Docker

Nathan Sparks edited this page Jul 8, 2017 · 29 revisions

Working with Docker

hdpm uses Docker as a tool for packaging Linux binaries for CentOS 6/7 and Ubuntu 16.04 LTS. sim-recon and its dependencies are built inside a Docker container, starting from a Linux-distribution base image, and then the relevant binaries are extracted and packaged in a tarfile. The Dockerfiles and scripts used to carry this out are located in the docker directory.

Installing Docker

Follow the instructions for your operating system at https://docs.docker.com/engine/installation/.

Building an image

gxd is a wrapper tool, located in the docker directory, for building images. Build the CentOS 7 sim-recon image by running

cd <path_to_hdpm>/docker
gxd build c7

The instructions below assume you have built this image or have fetched the equivalent from a repository.

Fetching an image from a repository

docker pull <repository>:<tag>

Running a sim-recon container

For convenience, tag the image by running

docker tag <repository>:<tag> sim-recon

The command for running a container can grow very long; it is useful to wrap it in a bash function. In the docker directory, there is a script called shortcuts.sh. Go to your work directory and source the shortcuts script:

  • cd <work_directory>
  • Switch to a bash shell if needed.
  • source <path_to_hdpm>/docker/shortcuts.sh

Move or copy any input-data and config. files into your current directory for mounting.

To run the software, precede the usual command with the bash function dock. Multi-word commands must be enclosed in quotes.

dock "hd_root --config=parms.config hd_rawdata_030858_000.evio"

Development of sim-recon

Docker can also be used as a tool for development of sim-recon. First, setup a directory with the source code to be developed and a Dockerfile for building it:

  • cd <path_to_hdpm>/docker/buildfiles && mkdir dev && cd dev
  • git clone https://github.com/JeffersonLab/sim-recon
  • cp -p ../centos7/Dockerfile .

Insert the following lines below the FROM line in the Dockerfile in order to add your source code when building the image.

USER root
ADD sim-recon sim-recon
RUN chown -R gx:gx sim-recon
USER gx

Update your local sim-recon directory, and then build it in a container by running

docker build -t sim-recon:dev .