Here's the unified command to flatten a Docker image by exporting and re-importing it (removes layer history):
docker export your_source_container | docker import - target_image:target_tag