ActiveState language distributions on Docker
The ActiveState language distributions for Docker are configured to get you up and running quickly with the core language distribution and all of the included community packages.
The following ActiveState languages and versions are available as Docker images:
- ActiveGo 1.8
- ActivePerl 5.26, 5.24, and 5.22
- ActivePython 2.7 and 3.5
The ActiveState language distribution images are based on the CentOS 7 Linux distribution. Docker clients are available to run the Docker images on Windows, macOS, or Linux.
For complete documentation for any of the ActiveState language distributions, see docs.activestate.com.
You need to install the Docker client for your operating system before you can download the ActiveState language images.
- Docker for macOS installation
- Docker for Windows installation
- Docker for Linux installation - See the instructions for specific Linux distributions: CentOS Debian Fedora Ubuntu
Accessing the Docker containers
Docker Hub is a central repository for Docker container images. It hosts an ActiveState repository with all of our available images.
- Create a Docker Hub account at hub.docker.com, or use your existing account, and log in.
- Navigate to the ActiveState repository at https://hub.docker.com/u/activestate/dashboard/.
- Click the link for the language you are interested in, and then click on the Tags tab to view the available versions for the language.
Downloading and starting a container
To ensure that you download the latest version of the image, use
docker pull to download the image, and then use
docker run to start a new container.
docker pull activestate/activepython:22.214.171.12405 docker run -it activestate/activepython:126.96.36.19905
These commands download the ActivePython 3.5.3 image, and then run a container based on the image in interactive mode. In interactive mode you have access to Linux shell commands and you can use the command line tools included in the ActiveState language distribution. For example, enter
python to work with ActivePython interactively if your are working with an ActivePython image. To exit the container, type
To download a specific version of an image, you need to specify the tag to retrieve using the syntax:
ActiveState/repository:tag. There is a repository for each ActiveState language distribution, and tags for each released version that is available for the language.
You can use tags to get the latest revision, or to select the precise image you need:
:latest- The latest version of the repository. For example:
:version- A specific version of the repository. For example:
:version-baseImage- A specific version built from a specific base image. For example:
:version-baseImage-revision- A specific version that uses a specific base image and revision. For example:
Using a Dockerfile to configure and launch your container
You can use a Dockerfile to create your own customized image based on one of the ActiveState Docker images. This allows you to configure the container with all of the settings and prerequisites required by your application. You can also use Docker Compose to link the ActiveState language containers with other containers, such as a container for the backend database or web server used by your application. This allows you to standardize your application environment in containers from development through to production.
The following example of a Dockerfile for ActivePython performs a number of actions to enable the application to run:
- It creates a new image based on the ActivePython image
- It sets environment variables and creates directories
- It copies the needed files from the project directory on the local machine to the Docker container
- It executes a script to launch the application
FROM activestate/activepython:188.8.131.5205 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/ CMD [ "python", "./test-script.py" ]
The example assumes that there is a workspace directory that contains the
requirements.txt file, and the Python script file.
docker build -t my-python-app . docker run -it -rm --name my-running-app my-python-app
The ActivePython distribution is installed into the
/opt/activepython-<version>/ folder, with the PATH configured to run Python commands.
For version 3.x images, symbolic links are included to associate
pip with the ActivePython distribution.
Additional packages included in the ActivePython distributions are located in
/opt/ActivePython-<version>/lib/python-<version>/site-packages. You can list them by entering
pip freeze at the command prompt.
The ActivePerl distribution is installed into the
/opt/activepython-<version>/ folder, with the PATH configured to run Perl commands.
The ActiveGo distribution is installed into the
/opt/activego-<version>/ folder, with the PATH configured to run Go commands.
To execute Go as soon as the container starts, you can pass
go along with the required arguments in the
docker run command:
docker run -it activestate/activego:184.108.40.206 "go build"