---
title: How to build and push a container image
description: How to build and push a container image based on a Dockerfile for deploying containerized applications with Scaleway Serverless Jobs.
tags: create dockerfile containerize application deployment scaleway
dates:
  validation: 2025-10-21
  posted: 2021-04-01
---

This page explains how to create a simple Dockerfile to containerize your applications for deployment using Scaleway Serverless Jobs.

## How to Write a Dockerfile

1. Create a file named `Dockerfile` in your project directory.

2. Add the following content to your Dockerfile, adjusting the base image and commands according to your application:

<Tabs>
<TabsTab label="Go">
```dockerfile
# Use the official Golang image to create a build artifact.
FROM golang:1.24-alpine AS builder

# Create the main.go file with the Go source code
RUN echo 'package main

import "fmt"

func main() {
    fmt.Println("Hello from Scaleway Serverless Jobs!")
}' > main.go

# Build the Go app
RUN go build -o main .

# Start a new stage from scratch
FROM alpine:latest

# Copy the Pre-built binary file from the previous stage
COPY --from=builder /app/main .

# Command to run the executable
CMD ["./main"]
```
</TabsTab>
<TabsTab label="Python">
```dockerfile
FROM python:3.13-slim

# Single-line Python script as entrypoint
CMD ["python", "-c", "print('Hello from Scaleway Serverless Jobs!')"]
```
</TabsTab>
<TabsTab label="Rust">
```dockerfile
FROM rust:1.86-slim

# Pre-compile a Rust binary during build
RUN echo 'fn main() { println!("Hello from Scaleway Serverless Jobs!"); }' > main.rs && \
    rustc main.rs

# Run the pre-compiled binary
CMD ["./main"]
```
</TabsTab>
</Tabs>

## How to build and push your image from your Dockerfile

1. Open a terminal and navigate to the directory containing your Dockerfile.

2. Run the following command to build your Docker image:

    ```bash
    docker build --platform linux/amd64 -t my-application .
    ```

    <Message type="note">
    Make sure to add the `--platform linux/amd64` argument if you build your image on an ARM64 machine, as Serverless Jobs only handle `amd64` images.
    </Message>

3. Run the command below to log in to your Scaleway account in the terminal. Make sure that you replace the placeholder values with your own.

    ```bash
    docker login rg.fr-par.scw.cloud/your-container-registry-namespace -u nologin --password-stdin <<< "$SCW_SECRET_KEY"
    ```

4. Tag your Docker image so it matches your Scaleway registry's format:

    ```bash
    docker tag my-application:latest rg.fr-par.scw.cloud/your-container-registry-namespace/my-application:latest
    ```

5. Push the Docker image to the Scaleway Container Registry:

    ```bash
    docker push rg.fr-par.scw.cloud/your-container-registry-namespace/my-application:latest
    ```

You can now access your container image from the [Scaleway Container Registry](https://console.scaleway.com/registry/namespaces), and [deploy a Serverless Job](/serverless-jobs/reference-content/deploy-job/) from this image.

<Message type="tip">
You can build, tag and push your image to your Container Registry in a single command using the following syntax:
    ```bash
    docker build \
      --platform linux/amd64 \
      --push \
      -t your-container-registry-endpoint/my-application:latest .
    ```
</Message>
