Overview
This SAS Note provides a sample script for building a Docker container to enable SAS Analytics for Containers. This sample script is provided "as is," and is intended as a reference example only.
There are several ways to build a Docker container; in this example we are building a container with a file named Dockerfile.
Important: Before using the information in this SAS Note, read carefully the Disclaimer of Warranty and Limitation of Liability sections, below.
Prerequisites
To use this sample, you must have a solid working knowledge of Linux and of Docker container concepts.
It is assumed that the SAS Analytics for Containers offering for Linux x86_64 has already been installed in a Linux environment, and a tar archive has been created from the SAS installation directory. In the example, the archive is named SASHome.tar.
During the SAS deployment process, you must ensure that all content is stored under a single directory location. In particular, the SAS Studio Basic configuration directory must be included within the installation directory, which is not the default location. This default directory location is created as part of the installation, but you need to change it to the installation directory rather than the default.
Additional Requirements
-
A tar archive from a Linux x86_64 installation of the SASHome - from the SAS Analytics for Containers installation
-
Docker 1.09 or later installed
-
A Dockerfile to produce your SAS image (see the sample below)
Sample Dockerfile
Note: Items shown in all capital letters are Docker required terms.
FROM centos
MAINTAINER Joe Sasman JoeSasman@company.com
## install necessary libraries
RUN yum -y install numactl-libs.x86_64
RUN yum -y install libXp
RUN yum -y install passwd
RUN yum -y install libpng12
RUN yum -y install libXmu.x86_64
## example adding staff group
RUN useradd -m sas
RUN groupadd -g 1001 sasstaff
#### example adding sas user
RUN usermod -a -G sasstaff sas
## set default password for this example only
## another technique - point to /etc/passwd
RUN echo -e "foobar" | /usr/bin/passwd --stdin sas
## make SASHome directory
RUN mkdir -p /usr/local/SASHome
ADD SASHome.tar /
RUN chown -R sas:sasstaff /usr/local/SASHome
EXPOSE 38080
## An optional startup script can be added (more details below)
ADD startup.sh /
ENTRYPOINT ["/startup.sh"]
The optional startup.sh convenience script contains the following:
#! /bin/bash
/usr/local/SASHome/SASFoundation/9.4/utilities/bin/setuid.sh
/usr/local/SASHome/sas/studioconfig/sasstudio.sh start
tail -f /dev/null
Building a Docker Container from a Dockerfile
- With the Dockerfile, the SASHome.tar file, and the optional start-up script in the directory, issue the following docker build command to build the Docker image:
docker build -t sa4c:v1 .
- To display the image that was created, issue this command:
docker images
Running a Docker Container
Now that you have created a container, you can run it using the docker run command:
docker run -d -p 38080:38080 sa4c:v1
Disclaimer of Warranty
This instruction is provided to you "as is" without any warranties, express or implied, including but not limited to implied warranties or merchantability and/or fitness for a particular purpose. The Institute and its licensor(s) disclaim any liability connected with the use of the instruction. The Institute offers no technical support for the instruction.
Limitation of Liability
The Institute and its licensor(s) are not liable for (a) incidental, consequential, special, or direct damages of any sort, whether arising in tort, contract or otherwise, even if the Institute has been informed of the possibility of such damages, or (b) any claim by any other party. Some jurisdictions do not allow the exclusion or limitation of liability for incidental or consequential damages, so this limitation and exclusion may not apply to you.