How to access file mounts in initialization commands when using docker?

I need to access the file_mounts during the initialization commands. This is so I can do things like read env variables from a file or run shell scripts in initialization commands.

Is there a way I can do this? I’m also using the docker option.
I can currently use the following:


to access my files during the initialization phase, but it’s a bit hacky

if you’re using docker, it’s usually assumed that you shouldn’t be messing with the host machine too much. could you say more about what you’re trying to do?

If it’s just a few variables, you could consider baking them into your config file, or if it’s big you could consider baking them into your AMI.

I wanted to install tailscale on the host nodes; so I could SSH into the actual node, and not the docker container it was running.

For something like that, I would generally recommend putting tailscale on the AMI, using a credentials/secrets manager (if necessary), and initialization commands to just kick it off.

I try to bake things into the AMI, but it ends up being the case that I often need 10-30 lines of BASH to setup the instance fully, which can be somewhat unwieldy to just stick inside yaml.

Here’s what I’m currently using:

#! /usr/bin/env bash
set -euxo pipefail

# Load env vars
set -a
source .env
set +a

if [[ -z "${TAILSCALE_AUTH_KEY}" ]]; then
	echo "TAILSCALE_AUTH_KEY is not set"
	exit 1

sudo tailscale up --ssh --auth-key ${TAILSCALE_AUTH_KEY}

if [[ -f "$HOME/.SKIPDOCKERPULL" ]]; then
	echo "Skipping docker pull"
	exit 0

if [[ -z "${ECR_REGION}" ]]; then
	echo "ECR_REGION is not set"
	exit 1

account_id=$(aws sts get-caller-identity | jq -r .Account)

echo "Logging into repository: ${repository_base}"

login_password=$(aws ecr get-login-password --region ${ECR_REGION})
echo ${login_password} | docker login --username AWS --password-stdin ${repository_base}