Create a Container Image
This guide explains how to build and publish your own Docker container image using a simple website running on NGINX. The final result will be an image you can use on the Serverless Containers platform.
Prerequisites
-
Docker
Install Docker on your machine: https://www.docker.com/ -
Online Repository
Have access to a container registry such as Docker Hub.
Steps
Step 1: Write Your Application
Start by creating your application. In this example, it’s a basic HTML website.
Save the following content in a file named index.html
inside a folder called My_Test_Website
:
This tells Docker to use NGINX and serve the contents of your website.
Step 3: Build the Docker Image
Open a terminal, navigate to the ~/ServerlessContainers
directory, and run:
To tag it for your container registry (e.g., Docker Hub), use your registry name:
This builds and tags your Docker image.
Step 4: Test Your Docker Container
Run your newly built container:
This runs the container in the background and maps container port 80 to your local machine’s port 8080.
To check if it's running:
Example output:
You can now open http://localhost:8080 in your browser and see your website.
Step 5: Upload to Your Container Registry
Login to Docker Hub:
Enter your username and personal access token (or password).
Push your image:
This uploads your image to your online container registry.
What's Next
You're ready to upload your image to the Serverless Containers platform.
- Deploy a Container on Serverless Containers
- Connect a Domain to Your Container
- Use Persistent Storage
For more information, check out the Docker documentation.