Dockerfileã«ãå½ç¶ãã¹ããã©ã¯ãã£ã¹ãåå¨ããããããã§ãã¯ããLinterãåå¨ãã¾ãã
- Best practices | Docker Docs
- GitHub - hadolint/hadolint: Dockerfile linter, validate inline bash, written in Haskell
ãã®ãã¹ããã©ã¯ãã£ã¹ã¨å¼ã°ãã1ã¤ã«ãapt-get installã§ã®version pinãããã¾ãã
version pinã¨ã¯
ä¸è¨ã§è¨ãã°ãapt-get installã§ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããéãæ示çã«ããã±ã¼ã¸ãã¼ã¸ã§ã³ãæå®ãããã¨ã§ãã Datadogã®ããã°è¨äºã«ãããã®ãã¹ããã©ã¯ãã£ã¹ãç´¹ä»ããã¦ãã¾ãã
version pinã¨ãã£ã¦ãå ·ä½çã«ã©ããããã®ããã¨ãªãã®ã§ããã¹ããã©ã¯ãã£ã¹ã«åã£ãä¾ãä¸è¨ã¨ã³ããªããå¼ç¨ãã¾ãã
FROM debian:12 RUN apt-get install python=3.11
ããã§ã¯ãPythonã®ãã¼ã¸ã§ã³ã3.11ã«åºå®ãããã¨ã§ãåæã«3.12ãªã©ãã¤ã³ã¹ãã¼ã«ããã¦ãã¾ããããã«ããäºæãã¬åä½ã®å¤æ´ãé²ãã¾ããè¦ããã«ããã«ãã®åç¾æ§ãé«ãã¦ããããã§ããã
version pinã®ã¡ã³ããè¾ã
åã¯hadolintã«æãããããã«ããã®version pinãå°å
¥ãã¾ããããããããããçµæ§é¢åãªãã§ãããã
ä½ãé¢åãªã®ãã¨ããã¨ãããã±ã¼ã¸ãªãã¸ããªã容éã¯æéãªã®ã§ãå¤ããã¼ã¸ã§ã³ã®ããã±ã¼ã¸ãåé¤ããã¦ãã¾ããã§ãããçµæã¨ãã¦ãDockerfileã¯å¤ãã¦ããªãã®ã«ããã«ãã失æãããã¨ã«ãªã£ã¦ãã¾ã£ãããã«ãã®åç¾æ§ãé«ããã¯ãããéã«åç¾æ§ãå´©ãã¦ãã¾ã£ãããã§ãã
ã¾ãããã¼ã¹ã¤ã¡ã¼ã¸ã¿ã°ãå³å¯ã«æå®ãã¦ããªãä¸ã§ããã±ã¼ã¸ã®ã¿version pinãè¡ã£ãããå½ç¶ãã«ãã¯å¤±æãããããªãã¾ãã
ä»å¾ã©ãããã
ãã¡ãããã¹ã¦ã®ãã¼ã¸ã§ã³ãã¬ãã¬ãã«åºããããã°çæ³çããããã¾ããããã»ãã¥ãªãã£ã¢ãããã¼ãçãåãè¾¼ãããä¸è¨ã®ããã«ãã«ããå£ãã¦ãã¾ã£ãä¸ã§ãã¤ãã¤ãversion pinã®ã¡ãªãããæãããã¾ãããããversion pinã¯è«¦ãã¦ããã«ããå£ãããèãããã¨ãããã¨ã«ãããã
ã§ãã©ããªãã§ããããJavaãPythonãGoããå©ç¨ããã©ã¤ãã©ãªã®ãã¼ã¸ã§ã³ã¯ããã¯ãã¦ãã¹ããè¡ãããããæ¬çªç°å¢ã«åæ ããã®ãä¸è¬çã§ããã¢ããªã±ã¼ã·ã§ã³ãå©ç¨ããç°å¢ã«ããããã±ã¼ã¸ã¯ã©ãã¾ã§ããã¯ããã¹ããªã®ããã¨ããã®ã¯é£ããåé¡ã§ããã
ãã®è©±ãçµå±ã®ã¨ããå æ¬çãªãã¹ããç°¡åã«ã§ããããã«ããããã¨ãã話ã«ãªãããã§åä»ãªãã ããªã