Using User Data with Docker CE Cloudformation

Expected behavior

Bash scripts in User Data should install prerequisite applications, retain docker images pulled and keep files output to home directory.

Actual behavior

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 /home/apkLog to /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.

Additional Information

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

  1. Start Docker CE for AWS as normal with at least 3 manager instances
  2. 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/apkLog and echo "Test" > /home/test.txt)
  3. Edit the autoscaling group to use the new launch configuration.
  4. Terminate a manager instance and wait for replacement instance to boot and finish initializing.
  5. SSH into new manager instance.

Our recommendation is to just run git (and any other software you need) in containers running on top of Docker for AWS. Docker for AWS is a platform for running software using Docker, so the underlying instances are not built to be user serviceable.

Can you share more details on what objective you’re trying to achieve so we can come with better suggestions?

We’d like to be able to autoscale a web application and monitor some
instance level metrics. Being able to implement the AWS CLI without
creating more services and workarounds to get instance level metrics would
be very helpful. Being able to properly use AWS’s User Data would allow us
to deploy through Cloudformation completely.

What software are you planning to use to get the metrics? And what software is that you cannot deploy in Docker containers?