Docker containers

Using the State Tool you can easily embed an ActiveState language runtime inside a Docker container, and then use that runtime to run first party code. This is currently only available using Linux containers.

Below is a sample Dockerfile which will help you:

#Begin with a base image
FROM ubuntu

#SECTION 1: Install prerequisite utilities (will vary depending on base)
RUN apt-get update && apt-get install wget -y

#SECTION 2: Install the State Tool
RUN sh / /opt/ActiveState && ln -s /opt/ActiveState/bin/state /usr/local/bin

#SECTION 3: Install your runtime
#Authenticate with the AS Platform
#add --token <YourTokenHere> to avoid prompt

RUN state auth
#Install any runtime you would like from the AS Platform and make it the default
RUN state activate ORG/PROJECT --default

#Section 4 [Optional]: Run your app

#Copy in your first party code
#Use the State Tool to execute your code using the default runtime
CMD state exec python3

After successfully embedding your ActiveState runtime into your Docker container, you can:

Section 1: Install prerequisite utilities

The example Dockerfile uses a base Ubuntu image, a CentOS example is included after. Start by modifying the Ubuntu base image and adding the utilities necessary for successful integration with ActiveState.

Ensure that your modified base image has the following non-system utilities in order to get the State Tool installed and working properly, as different base images will be missing different needed utilities.

  • Curl or wget
  • Tar or gzip
  • Sed

If your base image was CentOS instead of Ubuntu, Section 1 may look like the image below. You will need to customize Section 1 depending on which base image you use.

#Section 1 (CENTOS): Install prerequisite utilities
FROM centos
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=|baseurl=|g' /etc/yum.repos.d/CentOS-*
RUN yum install ncurses -y && yum install file -y

Section 2: Install The State Tool

The steps to install the State Tool will be the same for all of the Linux distros. The commands shown in this section will download the State Tool installer script, execute it, and configure the State Tool with the correct permissions and symbolic links.

Section 3: Install your runtime

To install your runtime you will need to first authenticate with the ActiveState platform and then install a default Python runtime into the image.

The authentication step is interactive. Please copy the web address produced during the image build process (shown below).


and authorize it to proceed with building the image by clicking the “Authorize” button.


The command terminal may have formatting that will prevent you from copying and pasting the link directly into your browser. The format of the link should have the following convention:<token string>.

If you don’t want to authenticate interactively you can supply a jwt token. The token is shown after RUN state auth in your command terminal, or as a string in your URL link.

After authenticating your account, go to your Dockerfile and replace ORG with the name of your organization on the ActiveState platform and PROJECT with the name of the ActiveState platform project containing your runtime. Ensure the project is configured to support the OS of the container. For example, using Ubuntu this will be Linux Glibc 2.28.

Section 4: (Optional): Run your app

To configure your image to run first party code (“” in the example Dockerfile) using the Python runtime embedded in the image. First, we copy in our first party code and then use the State Tool command state exec to run our python program with python3

Building Your Image

Once you have prepared your Dockerfile, build it into an image using the command below.

docker build --no-cache -t ActiveStateImage <pathToFolderWithDockefile>

Run Your Container

You can now launch a container using thi command. The container will run, execute the CMD, and then exit.

docker run ActiveStateImage

Use your State Tool Interactively In a Container

To use the State Tool interactively in a container, spin one up using the image created previously and run it in interactive mode using the command below.

docker run -it ActiveStateImage /bin/bash

Note if you leave your container running you can reconnect to a new shell process by using this command.

docker exec -it ActiveStateImage /bin/bash

Once you are connected to a container you will be able to execute State Tool commands including activating an ActiveState runtime. Type state to see your options. This mode of operation can be helpful for development or in highly secure IT environments because the container environment is logically isolated from the rest of your machine and you will have root privileges.

If the goal is to build an image solely for this use case you won’t need to install a default runtime or any application code. Sections 3 and 4 from our Dockerfile are not necessary and can be removed.