Skip to main content
Version: Latest

Init Scripts

Check your docs version

These docs are for the new Anyscale design. If you started using Anyscale before April 2024, use Version 1.0.0 of the docs. If you're transitioning to Anyscale Preview, see the guide for how to migrate.

An init script is a shell script that runs inside the Ray container on all nodes before Ray starts. Common use cases include:

  • Performing commands to fetch resources or other runtime dependencies
  • Installing container-based monitoring/security agents
  • Pre-job testing and verification for complex health-checks (for example, verifying network paths before starting jobs)

To add init scripts to your container image, write them into /anyscale/init.

All output from init scripts is written into /tmp/ray/startup-actions.log. If init scripts fail to execute on a node, standard output and standard error will be shown in the Event Log for the cluster associated with your Job/Service/Workspace, and the node will be terminated.

FROM anyscale/ray:2.30.0-slim-py310

# Create the directory
RUN sudo mkdir -p /anyscale/init

# Scripts run alphabetically: script1 then script2
RUN echo 'date | sudo tee /tmp/script1.txt' | sudo tee /anyscale/init/script1.sh
RUN sudo chmod +x /anyscale/init/script1.sh

RUN echo 'date | sudo tee /tmp/script2.txt' | sudo tee /anyscale/init/script2.sh
RUN sudo chmod +x /anyscale/init/script2.sh