How do I create a custom image?


How do I create a custom image?

Last updated November 28th, 2016
  1. Navigate to the 'Containers' module, then click on 'Images'.

    Custom Images

    If you are about to create your very first custom image, you should see a message similar to the one shown below. Click the 'Create Custom Image' button to get started:

    No images

  2. You will now need to enter the name for your custom image, and whether you would like to fork this image from one of our pre-made images. In this case we are going to fork from the Apache + PHP 7.0 image.

    Create Image

    Learn more about the difference between forking an image and starting from scratch.

  3. If this is your first custom image, you won't have any SSH keys that have access. We will select our SSH key and click 'Create Image', this allows you to clone the image to your local machine.

    Select SSH Keys

    Read more about SSH Keys and custom images.

  4. You will now see that your custom image is in the progress of being created. This should only take a few moments, once your image is created click on its name to see more details.

    Select Image

  5. Here we can see all of the details about our custom image, the repository url (which we will use shortly) and the current image versions if you have some.

    Select Image

    Learn more about image versions.

  6. We will now clone the repository to our local machine. We are assuming that you already have git installed, if not install it now.

    $ git clone
    $ cd ./my-custom-image
  7. Inside our repository you will find all the files and folder structure we need to build a custom image.

    $ ls -lah
     > drwxrwxr-x  6 user user 4.0K Nov 28 12:04 default-data
     > -rw-rw-r--  1 user user   67 Nov 28 12:04 Dockerfile
     > drwxrwxr-x  8 user user 4.0K Nov 28 12:04 .git
     > -rw-rw-r--  1 user user  605 Nov 28 12:04 .gitlab-ci.yml
     > -rw-rw-r--  1 user user  393 Nov 28 12:04 manifest.yml

    As you can see our repository contains 3 files: .gitlab-ci.yml, manifest.yml and Dockerfile These 3 files are mandatory in every custom image, they define exactly how to build your custom image.

    When making a custom image from scratch, you will mainly be changing manifest.yml and Dockerfile. You can read more about the manifest.yml file.

    The .gitlab-ci.yml file is used to build your custom image in our CI environment, we do not allow any changes to this file. Any commit that alters this file will be rejected.

    You will also notice the default-data directory. This is where you store the files needed for your custom image. For more information please read about the default-data directory.

    Because we forked our image from the Apache + PHP 7.0 image, you will see inside default-data all the necessary files needed for this image.

  8. Let's change the index.html to index.php

    $ rm ./default-data/application/public/index.html
    $ echo "<?php phpinfo() ?>" > ./default-data/application/public/index.php

    We will now add those changes to our commit and push the changes. This will trigger an automatic build.

    $ git rm ./default-data/application/public/index.html
    $ git add ./default-data/application/public/index.php
    $ git commit -m "remove index.html, adding index.php"
    $ git push

    While the image is building, you can view the build status and build log from within the Control Panel. For more information, you can read about the build status and build log.

  9. Check the build status

    We can now see that our build was successful: Select Image

    Once an image has successfully finished building, you can now use it when creating containers.

Can we improve this article? Suggest an improvement to this article.

Suggest an Improvement

Thank you for helping us to improve this Knowledge Base article. Please type your suggestions below:

Still need help? Get in touch with us.

If you aren't able to find the help you need then please send us a question and we can help you further.