Create a custom container

This example creates a simple custom container that contains a python script in the /etc directory.

In this example, we will use a simple container file named test_lxc.tgz. You can download test_lxc.tgz from the Digi website.

At the command line of a Linux host, we will unpack the file, add a simple python script, and create a new container file that includes the python script.

Note You will need to have the Python live image installed on your device in order to use this example container file. See Install Python for more information.

Create the custom container file

  1. At the command line of a Linux host, unpack the test_lxc.tgz file:
    $ tar -xfv test_lxc.tgz
    rootfs/
    rootfs/usr/
    rootfs/etc/
    rootfs/etc/group
    rootfs/etc/profile
    rootfs/etc/passwd
    rootfs/tmp/
    $
  2. Change to the rootfs/etc directory:
    $ cd rootfs/etc
    $
  3. Create a file named test.py with the following contents:
    print("Hello world.\n")
  4. Change directories to leave the container file structure:

    $ cd ../..

  5. Change user and group permissions on all files in the container file structure:
    $ sudo chown -R 165536 rootfs
    $ sudo chgrp -R 165536 rootfs
    
  6. Tar and zip the directory structure to create a new container file:

    $ sudo tar -czvf python_lxc.tgz rootfs

    If using macOS, include the --disable-copyfile option with this command:

    $ sudo tar --disable-copyfile -czvf python_lxc.tgz rootfs

Test the custom container file

  1. Add the new container to your EX15 device:

      Log into the EX15 WebUI as a user with full Admin access rights.

    1. From the main menu, click Status. Under Services, click Containers.
    2. Click Upload New Container.
    3. From your local file system, select the container file.

      You can download a simple example container file, test_lxc.tgz, from the Digi website.

    4. Create Configuration is selected by default. This will create a configuration on the device for the container when it is installed. If deselected, you will need to create the configuration manually.
    5. Click Apply.
  2. Select a device in Remote Manager that is configured to allow shell access to the admin user, and click Actions > Open Console. Alternatively, log into the EX15 local command line as a user with shell access.

    Depending on your device configuration, you may be presented with an Access selection menu. Type shell to access the device shell.

  3. At the shell prompt, type:

    # lxc python_lxc
    lxc #

  4. Execute the python command:
    lxc # python /etc/test.py
    Hello world.
    lxc #