Skip to content
Fresh

Develop your app

Back

Guides

Bun language-specific guide

Learn how to containerize JavaScript applications with the Bun runtime.

JavaScript Docker Hardened Images

10 minutes

1

Containerize your app

2

Develop your app

3

Configure CI/CD

4

Test your deployment

« Back to all guides

Use containers for Bun development

Copy as Markdown

Open MarkdownAsk Docs AIClaudeOpen in Claude

Table of contents


Prerequisites

Complete Containerize a Bun application.

Overview

In this section, you'll learn how to set up a development environment for your containerized application. This includes:

  • Configuring Compose to automatically update your running Compose services as you edit and save your code

Get the sample application

Clone the sample application to use with this guide. Open a terminal, change directory to a directory that you want to work in, and run the following command to clone the repository:

console
$ git clone https://github.com/dockersamples/bun-docker.git && cd bun-docker

Automatically update services

Use Compose Watch to automatically update your running Compose services as you edit and save your code. For more details about Compose Watch, see Use Compose\ Watch.

Open your compose.yml file in an IDE or text editor and then add the Compose Watch instructions. The following example shows how to add Compose Watch to your compose.yml file.

<br&gt; 1<br&gt; 2<br&gt; 3<br&gt; 4<br&gt; 5<br&gt; 6<br&gt; 7<br&gt; 8<br&gt; 9<br&gt;10<br&gt;11<br&gt;12<br&gt;yaml<br&gt;services:<br&gt; server:<br&gt; image: bun-server<br&gt; build:<br&gt; context: .<br&gt; dockerfile: Dockerfile<br&gt; ports:<br&gt; - "3000:3000"<br&gt; develop:<br&gt; watch:<br&gt; - action: rebuild<br&gt; path: .<br&gt;

Run the following command to run your application with Compose Watch.

console
$ docker compose watch

Now, if you modify your server.js you will see the changes in real time without re-building the image.

To test it out, open the server.js file in your favorite text editor and change the message from {"Status" : "OK"} to {"Status" : "Updated"}. Save the file and refresh your browser at http://localhost:3000. You should see the updated message.

Press ctrl+c in the terminal to stop your application.

Summary

In this section, you also learned how to use Compose Watch to automatically rebuild and run your container when you update your code.

Related information:

Next steps

In the next section, you'll take a look at how to set up a CI/CD pipeline using GitHub Actions.

Configure CI/CD for your Bun application »