如何在 Dockerfile 中发表评论? [英] How do I make a comment in a Dockerfile?

查看:19
本文介绍了如何在 Dockerfile 中发表评论?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 Dockerfile.有没有办法在这个文件中发表评论?

I am writing a Dockerfile. Is there a way to make comments in this file?

Docker 是否有一个注释选项,它会占用一行的其余部分并忽略它?

Does Docker have a comment option that takes the rest of a line and ignores it?

推荐答案

您可以在行首使用 # 来启动 comment(# 之前的空格是允许的):

You can use # at the beginning of a line to start a comment (whitespaces before # are allowed):

# do some stuff
RUN apt-get update 
    # install some packages
    && apt-get install -y cron

字符串中间的

# 被传递给命令本身,例如:

#'s in the middle of a string are passed to the command itself, e.g.:

RUN echo 'we are running some # of cool things'

这篇关于如何在 Dockerfile 中发表评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆