packages/docs/docs/docker.mdx
We recommend the following structure for your Dockerfile. Read below about the individual steps and whether you need to adjust them.
FROM node:22-bookworm-slim
# Install Chrome dependencies
RUN apt-get update
RUN apt install -y \
libnss3 \
libdbus-1-3 \
libatk1.0-0 \
libgbm-dev \
libasound2 \
libxrandr2 \
libxkbcommon-dev \
libxfixes3 \
libxcomposite1 \
libxdamage1 \
libatk-bridge2.0-0 \
libpango-1.0-0 \
libcairo2 \
libcups2
# Copy everything from your project to the Docker image. Adjust if needed.
COPY package.json package*.json yarn.lock* pnpm-lock.yaml* bun.lockb* bun.lock* tsconfig.json* remotion.config.* ./
COPY src ./src
# If you have a public folder:
COPY public ./public
# Install the right package manager and dependencies - see below for Yarn/PNPM
RUN npm i
# Install Chrome
RUN npx remotion browser ensure
# Run your application
COPY render.mjs render.mjs
CMD ["node", "render.mjs"]
:::note
Click here to see an example for a render.mjs script you can use.
:::
FROM node:22-bookworm-slim
RUN apt-get update
RUN apt install -y \
libnss3 \
libdbus-1-3 \
libatk1.0-0 \
libgbm-dev \
libasound2 \
libxrandr2 \
libxkbcommon-dev \
libxfixes3 \
libxcomposite1 \
libxdamage1 \
libatk-bridge2.0-0 \
libcups2
COPY package.json package*.json yarn.lock* pnpm-lock.yaml* bun.lockb* bun.lock* tsconfig.json* remotion.config.* ./
COPY src ./src
COPY public ./public
If you use NPM, put the following in your Dockerfile:
RUN npm i
If you use Yarn or PNPM, add the packageManager field to your package.json (example: "packageManager": "[email protected]") and remove the npm line from step 3. Then put following in your Dockerfile:
RUN corepack enable
RUN pnpm i
RUN corepack enable
RUN yarn
RUN npx remotion browser ensure
COPY render.mjs render.mjs
CMD ["node", "render.mjs"]
Assuming you want to render the composition MyComp:
import {bundle} from '@remotion/bundler';
import {renderMedia, selectComposition} from '@remotion/renderer';
import {createRequire} from 'node:module';
const require = createRequire(import.meta.url);
const bundled = await bundle({
entryPoint: require.resolve('./src/index.ts'),
// If you have a webpack override in remotion.config.ts, pass it here as well.
webpackOverride: (config) => config,
});
const inputProps = {};
const composition = await selectComposition({
serveUrl: bundled,
id: 'MyComp',
inputProps,
});
console.log('Starting to render composition');
await renderMedia({
codec: 'h264',
composition,
serveUrl: bundled,
outputLocation: `out/${composition.id}.mp4`,
chromiumOptions: {
enableMultiProcessOnLinux: true,
},
inputProps,
});
console.log(`Rendered composition ${composition.id}.`);
:::note
We recommend setting the enableMultiProcessOnLinux option for this Docker image, available from v4.0.42. Read more
:::
Run
docker build -t remotion-app .
to build a Docker image called remotion-app.
Use the following command to run the image:
docker run remotion-app
By default, Docker containers are not allowed to use all memory CPUs . Consider:
--cpus and --cpuset-cpus flags with the docker run command. Example: --cpus=16 --cpuset-cpus=0-15No emojis are installed by default. If you want to use emojis, install an emoji font:
RUN apt-get install fonts-noto-color-emoji
Those fonts may have limited Character support enabled by default. If you need full support, install the following fonts:
RUN apt-get install fonts-noto-cjk
In Debian (and also Alpine), old packages are removed from the repositories once new versions are released. This means that pinning the versions will actually cause the Dockerfiles to break in the future. We choose Debian as the distribution because the packages get well tested before they get released into the repository.
If you are on a lower version than v4.0.0, add ffmpeg to the list of packages to install:
RUN apt-get install -y nodejs ffmpeg npm chromium
If you are on Remotion v3.3.80 or lower, tell Remotion where Chrome is installed:
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
Alpine Linux is a lightweight distribution often used in Docker. There are two known issues with it when used in conjunction with Remotion:
November 6th, 2024: Use node:22-bookworm-slim over node:20-bookworm to update to LTS and get a much smaller image. October 11th, 2023: Used the node:20-bookworm, which is faster to deploy and also Debian.
September 25th, 2023: Recommend setting enableMultiProcessOnLinux.
May 30th, 2023: Update document for Remotion 4.0.
April 15th, 2023: Unpinning the versions in Debian since it would cause breakage.
April 3rd, 2023: Changed the Alpine Docker image to a Debian one, since the versions of Alpine packages cannot be pinned. This makes the Debian one less likely to break.