Skip to main content
This guide explains Docker as a container engine that builds and uses images for application deployment. A Dockerfile serves as the recipe for building application images.

Prerequisites

  • Qovery CLI installed
  • Code hosted on GitHub
  • Basic understanding of Docker concepts

Overview

The tutorial recommends creating both a Dockerfile at the project root and a .dockerignore file to exclude unnecessary files from your image.

Dockerfile Instructions

FROM - Base Image

The first line you’ll add in your Dockerfile is FROM. This pulls an existing image from Docker Hub matching your application language:
Example:
Choose specific version tags (e.g., python:3.11) instead of latest for reproducible builds.

WORKDIR - Working Directory

Sets the working directory within the container:
All subsequent commands will be executed from this directory.

COPY - Copy Source Code

Copies your source code into the image:
You can also specify specific source/destination paths using relative directories:

RUN - Execute Commands

Executes commands for installing dependencies and building applications:
Examples:

EXPOSE - Open Ports

Opens ports for external access:
Example:
Important: Your application must listen on all interfaces (0.0.0.0), not localhost (127.0.0.1), for the container to be accessible.
Correct binding examples:

CMD - Execute Application

Specifies how to execute the application:
Examples:

Complete Dockerfile Examples

Python Flask Application

Node.js Express Application

Multi-stage Go Application


.dockerignore File

Create a .dockerignore file to exclude unnecessary files:

Building Your Image

Local Testing

Test your Docker image locally:

Testing with Qovery CLI

Test with Qovery CLI before deploying:
This builds and runs your application locally, simulating the Qovery environment.

Best Practices

Combine RUN commands when possible:
Reduce final image size by separating build and runtime stages:
Copy dependency files before source code:
Always create a .dockerignore file to exclude unnecessary files from your build context.

What’s Next

Once your Dockerfile is ready, you can deploy your application to Qovery:

Deploy Your First Application

Step-by-step deployment guide

Application Configuration

Configure your application settings

Environment Variables

Manage environment variables

Ports Configuration

Configure application ports