Bash scripts in User Data should install prerequisite applications, retain docker images pulled and keep files output to home directory.
Using commands related to installed packages receives an error message stating that they aren’t found such as
ash: vim: not found. However if logs of the installation process are taken, they indicate these packages installed correctly and are used later in the User Data script. Files created in running User Data no longer exist after ssh-ing into the instance. Changing where the script writes to (for example from
/var/log/apkLog) causes the files to remain. Docker images pulled can be logged and show that they’ve been successfully pulled but they are not listed under
docker images when ssh-ing in later.
Our cloudformation template is based off of Docker CE for AWS 17.06.0-ce (17.06.0-ce-aws2).
Steps to reproduce the behavior
- Start Docker CE for AWS as normal with at least 3 manager instances
- Copy the launch configuration for manager instances but edit User Data to add packages and write to
/home/. (Add the lines
apk update && apk add git > /var/log/apkLogand
echo "Test" > /home/test.txt)
- Edit the autoscaling group to use the new launch configuration.
- Terminate a manager instance and wait for replacement instance to boot and finish initializing.
- SSH into new manager instance.