Skip to main content
This guide assumes you already have Docker Desktop installed.
Docker is a platform for packaging and running an application as a lightweight, portable container that encapsulates all the necessary dependencies.
To containerize the application, define a Dockerfile. It lists the instructions to initialize the container, copy your local project files into it, install dependencies, and start the application.
Dockerfile

Next, add a .dockerignore file. It uses the same syntax as .gitignore and lists the files and directories to exclude from every stage of the Docker build. For example:
.dockerignore

Run docker build to convert this Dockerfile into a Docker image, a self-contained template containing all the dependencies and configuration required to run the application. The -t flag names the image, and --pull tells Docker to download the latest version of the base image (oven/bun). The initial build takes longer, since Docker downloads all the base images and dependencies.
terminal

Now start a running container from the bun-hello-world image with docker run. The -d flag runs it in detached mode, and -p 3000:3000 maps the container’s port 3000 to port 3000 on your machine. The run command prints the container ID.
terminal

The container is now running in the background. Visit localhost:3000. You should see a Hello, World! message.
To stop the container, run docker stop <container-id>.
terminal

If you can’t find the container ID, docker ps lists all running containers.
terminal

See the Docker documentation for more advanced usage.