internals.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. package dockerfile
  2. // internals for handling commands. Covers many areas and a lot of
  3. // non-contiguous functionality. Please read the comments.
  4. import (
  5. "crypto/sha256"
  6. "encoding/hex"
  7. "errors"
  8. "fmt"
  9. "io"
  10. "io/ioutil"
  11. "net/http"
  12. "net/url"
  13. "os"
  14. "path/filepath"
  15. "sort"
  16. "strings"
  17. "time"
  18. "github.com/Sirupsen/logrus"
  19. "github.com/docker/docker/api/types"
  20. "github.com/docker/docker/api/types/backend"
  21. "github.com/docker/docker/api/types/container"
  22. "github.com/docker/docker/api/types/strslice"
  23. "github.com/docker/docker/builder"
  24. "github.com/docker/docker/builder/dockerfile/parser"
  25. "github.com/docker/docker/pkg/archive"
  26. "github.com/docker/docker/pkg/httputils"
  27. "github.com/docker/docker/pkg/ioutils"
  28. "github.com/docker/docker/pkg/jsonmessage"
  29. "github.com/docker/docker/pkg/progress"
  30. "github.com/docker/docker/pkg/streamformatter"
  31. "github.com/docker/docker/pkg/stringid"
  32. "github.com/docker/docker/pkg/system"
  33. "github.com/docker/docker/pkg/tarsum"
  34. "github.com/docker/docker/pkg/urlutil"
  35. "github.com/docker/docker/runconfig/opts"
  36. )
  37. func (b *Builder) commit(id string, autoCmd strslice.StrSlice, comment string) error {
  38. if b.disableCommit {
  39. return nil
  40. }
  41. if b.image == "" && !b.noBaseImage {
  42. return fmt.Errorf("Please provide a source image with `from` prior to commit")
  43. }
  44. b.runConfig.Image = b.image
  45. if id == "" {
  46. cmd := b.runConfig.Cmd
  47. b.runConfig.Cmd = strslice.StrSlice(append(getShell(b.runConfig), "#(nop) ", comment))
  48. defer func(cmd strslice.StrSlice) { b.runConfig.Cmd = cmd }(cmd)
  49. hit, err := b.probeCache()
  50. if err != nil {
  51. return err
  52. } else if hit {
  53. return nil
  54. }
  55. id, err = b.create()
  56. if err != nil {
  57. return err
  58. }
  59. }
  60. // Note: Actually copy the struct
  61. autoConfig := *b.runConfig
  62. autoConfig.Cmd = autoCmd
  63. commitCfg := &backend.ContainerCommitConfig{
  64. ContainerCommitConfig: types.ContainerCommitConfig{
  65. Author: b.maintainer,
  66. Pause: true,
  67. Config: &autoConfig,
  68. },
  69. }
  70. // Commit the container
  71. imageID, err := b.docker.Commit(id, commitCfg)
  72. if err != nil {
  73. return err
  74. }
  75. b.image = imageID
  76. return nil
  77. }
  78. type copyInfo struct {
  79. builder.FileInfo
  80. decompress bool
  81. }
  82. func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalDecompression bool, cmdName string) error {
  83. if b.context == nil {
  84. return fmt.Errorf("No context given. Impossible to use %s", cmdName)
  85. }
  86. if len(args) < 2 {
  87. return fmt.Errorf("Invalid %s format - at least two arguments required", cmdName)
  88. }
  89. // Work in daemon-specific filepath semantics
  90. dest := filepath.FromSlash(args[len(args)-1]) // last one is always the dest
  91. b.runConfig.Image = b.image
  92. var infos []copyInfo
  93. // Loop through each src file and calculate the info we need to
  94. // do the copy (e.g. hash value if cached). Don't actually do
  95. // the copy until we've looked at all src files
  96. var err error
  97. for _, orig := range args[0 : len(args)-1] {
  98. var fi builder.FileInfo
  99. decompress := allowLocalDecompression
  100. if urlutil.IsURL(orig) {
  101. if !allowRemote {
  102. return fmt.Errorf("Source can't be a URL for %s", cmdName)
  103. }
  104. fi, err = b.download(orig)
  105. if err != nil {
  106. return err
  107. }
  108. defer os.RemoveAll(filepath.Dir(fi.Path()))
  109. decompress = false
  110. infos = append(infos, copyInfo{fi, decompress})
  111. continue
  112. }
  113. // not a URL
  114. subInfos, err := b.calcCopyInfo(cmdName, orig, allowLocalDecompression, true)
  115. if err != nil {
  116. return err
  117. }
  118. infos = append(infos, subInfos...)
  119. }
  120. if len(infos) == 0 {
  121. return fmt.Errorf("No source files were specified")
  122. }
  123. if len(infos) > 1 && !strings.HasSuffix(dest, string(os.PathSeparator)) {
  124. return fmt.Errorf("When using %s with more than one source file, the destination must be a directory and end with a /", cmdName)
  125. }
  126. // For backwards compat, if there's just one info then use it as the
  127. // cache look-up string, otherwise hash 'em all into one
  128. var srcHash string
  129. var origPaths string
  130. if len(infos) == 1 {
  131. fi := infos[0].FileInfo
  132. origPaths = fi.Name()
  133. if hfi, ok := fi.(builder.Hashed); ok {
  134. srcHash = hfi.Hash()
  135. }
  136. } else {
  137. var hashs []string
  138. var origs []string
  139. for _, info := range infos {
  140. fi := info.FileInfo
  141. origs = append(origs, fi.Name())
  142. if hfi, ok := fi.(builder.Hashed); ok {
  143. hashs = append(hashs, hfi.Hash())
  144. }
  145. }
  146. hasher := sha256.New()
  147. hasher.Write([]byte(strings.Join(hashs, ",")))
  148. srcHash = "multi:" + hex.EncodeToString(hasher.Sum(nil))
  149. origPaths = strings.Join(origs, " ")
  150. }
  151. cmd := b.runConfig.Cmd
  152. b.runConfig.Cmd = strslice.StrSlice(append(getShell(b.runConfig), fmt.Sprintf("#(nop) %s %s in %s ", cmdName, srcHash, dest)))
  153. defer func(cmd strslice.StrSlice) { b.runConfig.Cmd = cmd }(cmd)
  154. if hit, err := b.probeCache(); err != nil {
  155. return err
  156. } else if hit {
  157. return nil
  158. }
  159. container, err := b.docker.ContainerCreate(types.ContainerCreateConfig{Config: b.runConfig}, true)
  160. if err != nil {
  161. return err
  162. }
  163. b.tmpContainers[container.ID] = struct{}{}
  164. comment := fmt.Sprintf("%s %s in %s", cmdName, origPaths, dest)
  165. // Twiddle the destination when its a relative path - meaning, make it
  166. // relative to the WORKINGDIR
  167. if dest, err = normaliseDest(cmdName, b.runConfig.WorkingDir, dest); err != nil {
  168. return err
  169. }
  170. for _, info := range infos {
  171. if err := b.docker.CopyOnBuild(container.ID, dest, info.FileInfo, info.decompress); err != nil {
  172. return err
  173. }
  174. }
  175. return b.commit(container.ID, cmd, comment)
  176. }
  177. func (b *Builder) download(srcURL string) (fi builder.FileInfo, err error) {
  178. // get filename from URL
  179. u, err := url.Parse(srcURL)
  180. if err != nil {
  181. return
  182. }
  183. path := filepath.FromSlash(u.Path) // Ensure in platform semantics
  184. if strings.HasSuffix(path, string(os.PathSeparator)) {
  185. path = path[:len(path)-1]
  186. }
  187. parts := strings.Split(path, string(os.PathSeparator))
  188. filename := parts[len(parts)-1]
  189. if filename == "" {
  190. err = fmt.Errorf("cannot determine filename from url: %s", u)
  191. return
  192. }
  193. // Initiate the download
  194. resp, err := httputils.Download(srcURL)
  195. if err != nil {
  196. return
  197. }
  198. // Prepare file in a tmp dir
  199. tmpDir, err := ioutils.TempDir("", "docker-remote")
  200. if err != nil {
  201. return
  202. }
  203. defer func() {
  204. if err != nil {
  205. os.RemoveAll(tmpDir)
  206. }
  207. }()
  208. tmpFileName := filepath.Join(tmpDir, filename)
  209. tmpFile, err := os.OpenFile(tmpFileName, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
  210. if err != nil {
  211. return
  212. }
  213. stdoutFormatter := b.Stdout.(*streamformatter.StdoutFormatter)
  214. progressOutput := stdoutFormatter.StreamFormatter.NewProgressOutput(stdoutFormatter.Writer, true)
  215. progressReader := progress.NewProgressReader(resp.Body, progressOutput, resp.ContentLength, "", "Downloading")
  216. // Download and dump result to tmp file
  217. if _, err = io.Copy(tmpFile, progressReader); err != nil {
  218. tmpFile.Close()
  219. return
  220. }
  221. fmt.Fprintln(b.Stdout)
  222. // ignoring error because the file was already opened successfully
  223. tmpFileSt, err := tmpFile.Stat()
  224. if err != nil {
  225. tmpFile.Close()
  226. return
  227. }
  228. // Set the mtime to the Last-Modified header value if present
  229. // Otherwise just remove atime and mtime
  230. mTime := time.Time{}
  231. lastMod := resp.Header.Get("Last-Modified")
  232. if lastMod != "" {
  233. // If we can't parse it then just let it default to 'zero'
  234. // otherwise use the parsed time value
  235. if parsedMTime, err := http.ParseTime(lastMod); err == nil {
  236. mTime = parsedMTime
  237. }
  238. }
  239. tmpFile.Close()
  240. if err = system.Chtimes(tmpFileName, mTime, mTime); err != nil {
  241. return
  242. }
  243. // Calc the checksum, even if we're using the cache
  244. r, err := archive.Tar(tmpFileName, archive.Uncompressed)
  245. if err != nil {
  246. return
  247. }
  248. tarSum, err := tarsum.NewTarSum(r, true, tarsum.Version1)
  249. if err != nil {
  250. return
  251. }
  252. if _, err = io.Copy(ioutil.Discard, tarSum); err != nil {
  253. return
  254. }
  255. hash := tarSum.Sum(nil)
  256. r.Close()
  257. return &builder.HashedFileInfo{FileInfo: builder.PathFileInfo{FileInfo: tmpFileSt, FilePath: tmpFileName}, FileHash: hash}, nil
  258. }
  259. func (b *Builder) calcCopyInfo(cmdName, origPath string, allowLocalDecompression, allowWildcards bool) ([]copyInfo, error) {
  260. // Work in daemon-specific OS filepath semantics
  261. origPath = filepath.FromSlash(origPath)
  262. if origPath != "" && origPath[0] == os.PathSeparator && len(origPath) > 1 {
  263. origPath = origPath[1:]
  264. }
  265. origPath = strings.TrimPrefix(origPath, "."+string(os.PathSeparator))
  266. // Deal with wildcards
  267. if allowWildcards && containsWildcards(origPath) {
  268. var copyInfos []copyInfo
  269. if err := b.context.Walk("", func(path string, info builder.FileInfo, err error) error {
  270. if err != nil {
  271. return err
  272. }
  273. if info.Name() == "" {
  274. // Why are we doing this check?
  275. return nil
  276. }
  277. if match, _ := filepath.Match(origPath, path); !match {
  278. return nil
  279. }
  280. // Note we set allowWildcards to false in case the name has
  281. // a * in it
  282. subInfos, err := b.calcCopyInfo(cmdName, path, allowLocalDecompression, false)
  283. if err != nil {
  284. return err
  285. }
  286. copyInfos = append(copyInfos, subInfos...)
  287. return nil
  288. }); err != nil {
  289. return nil, err
  290. }
  291. return copyInfos, nil
  292. }
  293. // Must be a dir or a file
  294. statPath, fi, err := b.context.Stat(origPath)
  295. if err != nil {
  296. return nil, err
  297. }
  298. copyInfos := []copyInfo{{FileInfo: fi, decompress: allowLocalDecompression}}
  299. hfi, handleHash := fi.(builder.Hashed)
  300. if !handleHash {
  301. return copyInfos, nil
  302. }
  303. // Deal with the single file case
  304. if !fi.IsDir() {
  305. hfi.SetHash("file:" + hfi.Hash())
  306. return copyInfos, nil
  307. }
  308. // Must be a dir
  309. var subfiles []string
  310. err = b.context.Walk(statPath, func(path string, info builder.FileInfo, err error) error {
  311. if err != nil {
  312. return err
  313. }
  314. // we already checked handleHash above
  315. subfiles = append(subfiles, info.(builder.Hashed).Hash())
  316. return nil
  317. })
  318. if err != nil {
  319. return nil, err
  320. }
  321. sort.Strings(subfiles)
  322. hasher := sha256.New()
  323. hasher.Write([]byte(strings.Join(subfiles, ",")))
  324. hfi.SetHash("dir:" + hex.EncodeToString(hasher.Sum(nil)))
  325. return copyInfos, nil
  326. }
  327. func (b *Builder) processImageFrom(img builder.Image) error {
  328. if img != nil {
  329. b.image = img.ImageID()
  330. if img.RunConfig() != nil {
  331. b.runConfig = img.RunConfig()
  332. }
  333. }
  334. // Check to see if we have a default PATH, note that windows won't
  335. // have one as its set by HCS
  336. if system.DefaultPathEnv != "" {
  337. // Convert the slice of strings that represent the current list
  338. // of env vars into a map so we can see if PATH is already set.
  339. // If its not set then go ahead and give it our default value
  340. configEnv := opts.ConvertKVStringsToMap(b.runConfig.Env)
  341. if _, ok := configEnv["PATH"]; !ok {
  342. b.runConfig.Env = append(b.runConfig.Env,
  343. "PATH="+system.DefaultPathEnv)
  344. }
  345. }
  346. if img == nil {
  347. // Typically this means they used "FROM scratch"
  348. return nil
  349. }
  350. // Process ONBUILD triggers if they exist
  351. if nTriggers := len(b.runConfig.OnBuild); nTriggers != 0 {
  352. word := "trigger"
  353. if nTriggers > 1 {
  354. word = "triggers"
  355. }
  356. fmt.Fprintf(b.Stderr, "# Executing %d build %s...\n", nTriggers, word)
  357. }
  358. // Copy the ONBUILD triggers, and remove them from the config, since the config will be comitted.
  359. onBuildTriggers := b.runConfig.OnBuild
  360. b.runConfig.OnBuild = []string{}
  361. // parse the ONBUILD triggers by invoking the parser
  362. for _, step := range onBuildTriggers {
  363. ast, err := parser.Parse(strings.NewReader(step), &b.directive)
  364. if err != nil {
  365. return err
  366. }
  367. total := len(ast.Children)
  368. for _, n := range ast.Children {
  369. if err := b.checkDispatch(n, true); err != nil {
  370. return err
  371. }
  372. }
  373. for i, n := range ast.Children {
  374. if err := b.dispatch(i, total, n); err != nil {
  375. return err
  376. }
  377. }
  378. }
  379. return nil
  380. }
  381. // probeCache checks if cache match can be found for current build instruction.
  382. // If an image is found, probeCache returns `(true, nil)`.
  383. // If no image is found, it returns `(false, nil)`.
  384. // If there is any error, it returns `(false, err)`.
  385. func (b *Builder) probeCache() (bool, error) {
  386. c := b.imageCache
  387. if c == nil || b.options.NoCache || b.cacheBusted {
  388. return false, nil
  389. }
  390. cache, err := c.GetCache(b.image, b.runConfig)
  391. if err != nil {
  392. return false, err
  393. }
  394. if len(cache) == 0 {
  395. logrus.Debugf("[BUILDER] Cache miss: %s", b.runConfig.Cmd)
  396. b.cacheBusted = true
  397. return false, nil
  398. }
  399. fmt.Fprintf(b.Stdout, " ---> Using cache\n")
  400. logrus.Debugf("[BUILDER] Use cached version: %s", b.runConfig.Cmd)
  401. b.image = string(cache)
  402. return true, nil
  403. }
  404. func (b *Builder) create() (string, error) {
  405. if b.image == "" && !b.noBaseImage {
  406. return "", fmt.Errorf("Please provide a source image with `from` prior to run")
  407. }
  408. b.runConfig.Image = b.image
  409. resources := container.Resources{
  410. CgroupParent: b.options.CgroupParent,
  411. CPUShares: b.options.CPUShares,
  412. CPUPeriod: b.options.CPUPeriod,
  413. CPUQuota: b.options.CPUQuota,
  414. CpusetCpus: b.options.CPUSetCPUs,
  415. CpusetMems: b.options.CPUSetMems,
  416. Memory: b.options.Memory,
  417. MemorySwap: b.options.MemorySwap,
  418. Ulimits: b.options.Ulimits,
  419. }
  420. // TODO: why not embed a hostconfig in builder?
  421. hostConfig := &container.HostConfig{
  422. Isolation: b.options.Isolation,
  423. ShmSize: b.options.ShmSize,
  424. Resources: resources,
  425. }
  426. config := *b.runConfig
  427. // Create the container
  428. c, err := b.docker.ContainerCreate(types.ContainerCreateConfig{
  429. Config: b.runConfig,
  430. HostConfig: hostConfig,
  431. }, true)
  432. if err != nil {
  433. return "", err
  434. }
  435. for _, warning := range c.Warnings {
  436. fmt.Fprintf(b.Stdout, " ---> [Warning] %s\n", warning)
  437. }
  438. b.tmpContainers[c.ID] = struct{}{}
  439. fmt.Fprintf(b.Stdout, " ---> Running in %s\n", stringid.TruncateID(c.ID))
  440. // override the entry point that may have been picked up from the base image
  441. if err := b.docker.ContainerUpdateCmdOnBuild(c.ID, config.Cmd); err != nil {
  442. return "", err
  443. }
  444. return c.ID, nil
  445. }
  446. var errCancelled = errors.New("build cancelled")
  447. func (b *Builder) run(cID string) (err error) {
  448. errCh := make(chan error)
  449. go func() {
  450. errCh <- b.docker.ContainerAttachRaw(cID, nil, b.Stdout, b.Stderr, true)
  451. }()
  452. finished := make(chan struct{})
  453. cancelErrCh := make(chan error, 1)
  454. go func() {
  455. select {
  456. case <-b.clientCtx.Done():
  457. logrus.Debugln("Build cancelled, killing and removing container:", cID)
  458. b.docker.ContainerKill(cID, 0)
  459. b.removeContainer(cID)
  460. cancelErrCh <- errCancelled
  461. case <-finished:
  462. cancelErrCh <- nil
  463. }
  464. }()
  465. if err := b.docker.ContainerStart(cID, nil, true, ""); err != nil {
  466. close(finished)
  467. if cancelErr := <-cancelErrCh; cancelErr != nil {
  468. logrus.Debugf("Build cancelled (%v) and got an error from ContainerStart: %v",
  469. cancelErr, err)
  470. }
  471. return err
  472. }
  473. // Block on reading output from container, stop on err or chan closed
  474. if err := <-errCh; err != nil {
  475. close(finished)
  476. if cancelErr := <-cancelErrCh; cancelErr != nil {
  477. logrus.Debugf("Build cancelled (%v) and got an error from errCh: %v",
  478. cancelErr, err)
  479. }
  480. return err
  481. }
  482. if ret, _ := b.docker.ContainerWait(cID, -1); ret != 0 {
  483. close(finished)
  484. if cancelErr := <-cancelErrCh; cancelErr != nil {
  485. logrus.Debugf("Build cancelled (%v) and got a non-zero code from ContainerWait: %d",
  486. cancelErr, ret)
  487. }
  488. // TODO: change error type, because jsonmessage.JSONError assumes HTTP
  489. return &jsonmessage.JSONError{
  490. Message: fmt.Sprintf("The command '%s' returned a non-zero code: %d", strings.Join(b.runConfig.Cmd, " "), ret),
  491. Code: ret,
  492. }
  493. }
  494. close(finished)
  495. return <-cancelErrCh
  496. }
  497. func (b *Builder) removeContainer(c string) error {
  498. rmConfig := &types.ContainerRmConfig{
  499. ForceRemove: true,
  500. RemoveVolume: true,
  501. }
  502. if err := b.docker.ContainerRm(c, rmConfig); err != nil {
  503. fmt.Fprintf(b.Stdout, "Error removing intermediate container %s: %v\n", stringid.TruncateID(c), err)
  504. return err
  505. }
  506. return nil
  507. }
  508. func (b *Builder) clearTmp() {
  509. for c := range b.tmpContainers {
  510. if err := b.removeContainer(c); err != nil {
  511. return
  512. }
  513. delete(b.tmpContainers, c)
  514. fmt.Fprintf(b.Stdout, "Removing intermediate container %s\n", stringid.TruncateID(c))
  515. }
  516. }
  517. // readDockerfile reads a Dockerfile from the current context.
  518. func (b *Builder) readDockerfile() error {
  519. // If no -f was specified then look for 'Dockerfile'. If we can't find
  520. // that then look for 'dockerfile'. If neither are found then default
  521. // back to 'Dockerfile' and use that in the error message.
  522. if b.options.Dockerfile == "" {
  523. b.options.Dockerfile = builder.DefaultDockerfileName
  524. if _, _, err := b.context.Stat(b.options.Dockerfile); os.IsNotExist(err) {
  525. lowercase := strings.ToLower(b.options.Dockerfile)
  526. if _, _, err := b.context.Stat(lowercase); err == nil {
  527. b.options.Dockerfile = lowercase
  528. }
  529. }
  530. }
  531. err := b.parseDockerfile()
  532. if err != nil {
  533. return err
  534. }
  535. // After the Dockerfile has been parsed, we need to check the .dockerignore
  536. // file for either "Dockerfile" or ".dockerignore", and if either are
  537. // present then erase them from the build context. These files should never
  538. // have been sent from the client but we did send them to make sure that
  539. // we had the Dockerfile to actually parse, and then we also need the
  540. // .dockerignore file to know whether either file should be removed.
  541. // Note that this assumes the Dockerfile has been read into memory and
  542. // is now safe to be removed.
  543. if dockerIgnore, ok := b.context.(builder.DockerIgnoreContext); ok {
  544. dockerIgnore.Process([]string{b.options.Dockerfile})
  545. }
  546. return nil
  547. }
  548. func (b *Builder) parseDockerfile() error {
  549. f, err := b.context.Open(b.options.Dockerfile)
  550. if err != nil {
  551. if os.IsNotExist(err) {
  552. return fmt.Errorf("Cannot locate specified Dockerfile: %s", b.options.Dockerfile)
  553. }
  554. return err
  555. }
  556. defer f.Close()
  557. if f, ok := f.(*os.File); ok {
  558. // ignoring error because Open already succeeded
  559. fi, err := f.Stat()
  560. if err != nil {
  561. return fmt.Errorf("Unexpected error reading Dockerfile: %v", err)
  562. }
  563. if fi.Size() == 0 {
  564. return fmt.Errorf("The Dockerfile (%s) cannot be empty", b.options.Dockerfile)
  565. }
  566. }
  567. b.dockerfile, err = parser.Parse(f, &b.directive)
  568. if err != nil {
  569. return err
  570. }
  571. return nil
  572. }
  573. // determine if build arg is part of built-in args or user
  574. // defined args in Dockerfile at any point in time.
  575. func (b *Builder) isBuildArgAllowed(arg string) bool {
  576. if _, ok := BuiltinAllowedBuildArgs[arg]; ok {
  577. return true
  578. }
  579. if _, ok := b.allowedBuildArgs[arg]; ok {
  580. return true
  581. }
  582. return false
  583. }