Last updated 6 months ago
Koyeb natively allows you to run your own, pre-built containers. With containers, you can embed all the system dependencies you need.
This is actually what we did in the Your first
Stack guide.
This time we will use a raw ubuntu
Docker image to experiment.
This example will execute cat /koyeb/events/in/raw
in an ubuntu
Docker
container each time the Koyeb Function is invoked.
The /koyeb/events/in/raw
is a Koyeb generated file, which is always
present in your containers and contains data about the event that triggered the
execution in JSON
format.
Our example will display the content of the event received by the container on stdout, which is readable in the logs.
1functions: 2 - name: "hello-container" # The function name 3 image: ubuntu # The Docker image to use 4 command: ["cat"] # Overrides the container default command 5 args: ["/koyeb/events/in/raw"] # The arguments of the command 6
The command
option of the YAML file allows you to override the default command specified with
CMD
in the Dockerfile of the container.
The args
option allows you to provide arguments to the default CMD
of the
Dockerfile or the command
you provided.
Now, you can Invoke your function with the pre-filled {"hello": "world"}
event data.
{"hello": "world"}
In your log files, you should see a JSON similar to:
If you forgot how to invoke your function or read logs, please refer to the invoke section of the Your First Stack Guide.
To read about deploying from your Private Docker Container Registry or an other public Container Registry, go to our Deploy from any Docker Container Registry.
Get in touch or create an account and deploy your serverless stack in minutes.