Migration into a Container

These instructions explain how to migrate your Posit Connect installation from a provisioned server or virtual machine (VM) into a container.

Prerequisites

  1. Either root or sudo access on the current Connect server.

    Managing the Connect service requires elevated privileges.

  2. Use PostgreSQL.

    Confirm that your Connect installation uses PostgreSQL before attempting to migrate into a container. If your installation still uses SQLite, migrate from SQLite to PostgreSQL.

    Note

    You can continue to use SQLite from a container if Connect will only ever run inside a single container. Almost all containerized installations require PostgreSQL.

  3. Connect variable data uses a networked file system.

    Confirm that your Connect installation uses a networked file system for its variable data before attempting to migrate into a container. If your installation still uses the local file system, migrate from local storage to NFS.

    Note

    You can continue to use a local file system mounted into a container if Connect will only ever run inside a single container. Almost all containerized installations require a networked file system.

  4. Upgrade Connect, if necessary.

    Confirm that the version of Connect on your current server matches the product version you intend to use in the container. Separate product upgrades from changes to your infrastructure.

  5. Obtain an image.

    You need to create or obtain an image to run Posit Connect. Posit provides a number of product images on Docker Hub. The source for those images is available on GitHub.

    If you are building your own container image, the basic Dockerfile in the Docker section may help you get started.

  6. Privileged container access.

    Note

    Privileged containers are not necessary when using off-host Kubernetes execution.

    In order to support process sandboxes, Posit Connect must be started with the CAP_SYS_ADMIN capability. The Privileged Containers and Sandboxing sections contain additional details.

  7. A Connect API key for an administrator account.

    You will use this API key to clear the runtime caches and optionally rebuild content after starting Connect in the new environment.

Workflow

Step 1: Stop Connect (server/VM)

Stop the Connect server.

sudo systemctl stop rstudio-connect

Step 2: Start Connect (container)

This command-line assumes that you are using one of the Connect images hosted on docker hub. The directory /mnt/connect is mounted into the container at the default /var/lib/rstudio-connect location and used for the Connect variable data.

docker run -d --privileged=true --rm \
    -p :3939:3939 \
    -v /mnt/connect:/var/lib/rstudio-connect \
    rstudio/rstudio-connect:jammy-2023.03.0

You may need to adjust this command for your environment and infrastructure.

Step 3: Route traffic

Adjust your infrastructure so your Connect requests are routed to and serviced by the container running Connect.

Step 4: Clear runtime caches & rebuild content

The content runtime caches containing the Python and R package dependencies for your content are incompatible with the Linux distribution and system libraries available within the target container.

You MUST clear these runtime caches and rebuild your deployed content.