AWS ec2's "user data" function in Docker

When build docker image, i can put a CMD to run a script or command in the container, but it is hard coded in the image and not flexible, I test with ONBUILD, still not flexible enough.

Can I have a feature to run “user data” as in aws ec2 instance when start a new container?

For example, I built an image, when I need start a new container with yum update -y, what can i do?