diff --git a/language-docker.cabal b/language-docker.cabal
--- a/language-docker.cabal
+++ b/language-docker.cabal
@@ -4,10 +4,10 @@
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: 309a0c933f6e5edbdfbe096391f0b79e6a6f9218347d912f390d58a9c7c7c475
+-- hash: a57fde3be580edb76aab82767e9e47bbe3cb585d5ea2af07eeb05b5331a5bac8
 
 name:           language-docker
-version:        10.4.0
+version:        10.4.1
 synopsis:       Dockerfile parser, pretty-printer and embedded DSL
 description:    All functions for parsing and pretty-printing Dockerfiles are exported through @Language.Docker@. For more fine-grained operations look for specific modules that implement a certain functionality.
                 See the <https://github.com/hadolint/language-docker GitHub project> for the source-code and examples.
diff --git a/src/Language/Docker/Parser/Prelude.hs b/src/Language/Docker/Parser/Prelude.hs
--- a/src/Language/Docker/Parser/Prelude.hs
+++ b/src/Language/Docker/Parser/Prelude.hs
@@ -209,10 +209,11 @@
   m <- heredocMarker
   heredocContent m
 
--- | Parses text until a heredoc is found. Will also consume the heredoc.
+-- | Parses text until a heredoc or newline is found. Will also consume the
+-- heredoc.
 untilHeredoc :: Parser Text
 untilHeredoc = do
-  txt <- manyTill anySingle heredoc
+  txt <- manyTill (anySingleBut '\n') heredoc
   return $ T.strip $ T.pack txt
 
 onlySpaces :: Parser Text
diff --git a/test/Language/Docker/ParseRunSpec.hs b/test/Language/Docker/ParseRunSpec.hs
--- a/test/Language/Docker/ParseRunSpec.hs
+++ b/test/Language/Docker/ParseRunSpec.hs
@@ -6,6 +6,7 @@
 import Test.HUnit hiding (Label)
 import Test.Hspec
 import TestHelper
+import qualified Data.List.NonEmpty as NonEmpty
 import qualified Data.Set as Set
 import qualified Data.Text as Text
 
@@ -532,3 +533,47 @@
       let file = "RUN <<EOF\necho $EOF\nEOF"
           flags = def {security = Nothing }
        in assertAst file [ Run $ RunArgs (ArgumentsText "echo $EOF") flags ]
+
+    -- This one is neccessary to make sure that we can both parse
+    -- RUN something <<EOF
+    -- bla
+    -- EOF
+    --
+    -- and not overshoot while parsing that `something` and accidentally parse
+    -- some docker instructions as well.
+    it "heredoc no overzealous parsing" $
+      let file =
+            Text.unlines
+              [ "RUN foo bar",
+                "FROM something",
+                "COPY <<EOF /foobar.sh",
+                "#!/bin/bash",
+                "echo foobar",
+                "EOF"
+              ]
+          flags = def
+       in assertAst
+            file
+            [ Run $ RunArgs (ArgumentsText "foo bar") flags,
+              From
+                ( BaseImage
+                    { image =
+                        Image
+                          { registryName = Nothing,
+                            imageName = "something"
+                          },
+                      tag = Nothing,
+                      digest = Nothing,
+                      alias = Nothing,
+                      platform = Nothing
+                    }
+                ),
+              Copy
+                ( CopyArgs
+                    [ SourcePath "EOF" ]
+                    (TargetPath "/foobar.sh")
+                    NoChown
+                    NoChmod
+                    NoSource
+                )
+            ]
