Skip to content

Working with Docker

Nathan A. Sparks edited this page Jan 10, 2016 · 29 revisions

Working with Docker

hdpm uses Docker as a tool for packaging Linux binaries for CentOS 6/7, Ubuntu 14, and Fedora 22, with sim-recon and its dependencies being built inside a Docker container, starting with a particular base image, and their binaries being extracted into a tarfile. The Dockerfiles and scripts for carrying this out are located in the "docker" directory. The images resulting from these builds are publicly available at either the Docker Hub or Quay. At Docker Hub, there is one repository for dependencies and another for an automated build of sim-recon. At Quay, there is just a single repository of sim-recon's dependencies for different Linux-distribution tags.

Installing Docker

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

Pulling images from repositories

  1. docker pull quay.io/nathansparks/sim-recon-deps:<tag>
  • tags: centos6 and centos7
  1. docker pull nathansparks/sim-recon-deps:<tag>
  • tags: ubuntu14 and fedora22
  1. docker pull nathansparks/sim-recon:centos6

Running a sim-recon container

The commands for running a container can grow very long; it is useful to collect them in a script. In the "docker" directory, there is a script called "shortcuts.sh". First, make a directory for mounting data into a running container, and modify the script to mount this directory:

  • cd <path_to_hdpm>/docker && mkdir data && cd data
  • cp -p ../shortcuts.sh .
  • Set DATA_DIR to the path of the directory you are currently in.
  • Switch to a bash shell if needed.
  • source shortcuts.sh

Create a more convenient (shorter) name/tag by running

docker tag nathansparks/sim-recon:centos6 sim-recon

To run the software, precede the usual command with the bash function dock. Multi-word commands must be enclosed in quotes. The following example requires the user to put the raw-data and parms.config files into the "data" directory for mounting, and in general, any data that needs to be mounted should be moved into that directory. Output files will be found in that directory as well.

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

Development

Docker can also be used to develop 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 .
  • Edit the Dockerfile to add your source code when building the image.
  • Delete or modify the MAINTAINER line.
  • Insert the following lines following the MAINTAINER or FROM line.
   USER root
   ADD sim-recon pkgs/sim-recon
   RUN chown -R hdpm:hdpm pkgs/sim-recon
   USER hdpm

Develop sim-recon, and then build it in a container by running

docker build -t sim-recon:dev .
Clone this wiki locally