加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Docker 基础 : Dockerfile

发布时间:2020-12-16 03:56:27 所属栏目:安全 来源:网络整理
导读:# This dockerfile uses the Ubuntu image# VERSION # Author: docker_user# Command format: Instruction [arguments / command] … 第一行必须指定基于的容器镜像 FROM ubuntu 维护者信息 MAINTAINER docker_user docker_user@email.com 镜像的操作指令 sp

# This dockerfile uses the Ubuntu image # VERSION # Author: docker_user # Command format: Instruction [arguments / command] …

第一行必须指定基于的容器镜像

FROM ubuntu

维护者信息

MAINTAINER docker_user docker_user@email.com

镜像的操作指令

<span style="color: #000000">RUN echo “deb http://archive.ubuntu.com/ubuntu/ raring main universe” >> /etc/apt/sources.list
RUN apt-get update && apt-get install -y nginx
RUN echo “ndaemon off;” >> /etc/nginx/nginx.conf

容器启动时执行指令

CMD /usr/sbin/nginx

RUN apt-get update && apt-get install -y inotify-tools nginx apache2 openssh-server

# Firefox over VNC RUN /.vnc # setup a password RUN -storepasswd ~/.vnc/ # Autostart firefox RUN ba -c ‘“firefox” >> /.bashrc’ EXPOSE CMD [“x11vnc”,“-forever”,“-usepw”,“-create”]

或 FROM:

,指定维护者信息。

LABEL = = = ...

LABEL =-with-value===

LABEL multi.label1= multi.label2= other=

LABEL multi.label1===

RUN RUN [“executable”,“param1”,“param2”]。

CMD command param1 param2 在 /bin/<span style="color: #0000ff">sh<span style="color: #000000"> 中执行,提供给需要交互的应用。

CMD [“param1”,“param2”] 提供给 ENTRYPOINT 的默认参数。

EXPOSE […]

。指定一个环境变量,会被后续 RUN 指令使用,并在容器运行时保持。例如:

ENV PG_MAJOR .-SL http: ENV PATH /usr/local/postgres-$PG_MAJOR/bin:$PATH

ADD

到容器中的 。其中 可以是 Dockerfile 所在目录的一个相对路径(文件或目录);也可以是一个 URL;还可以是一个 tar 文件(自动解压为目录)。

COPY

(为 Dockerfile 所在目录的相对路径,文件或目录) 为容器中的 。目标路径不存在时,会自动创建。当使用本地目录为源目录时,推荐使用 COPY。

ENTRYPOINT command param1 param2 (shell 中执行)

VOLUME ["/data"]

USER daemon

WORKDIR /path/to/workdir

WORKDIR /

ONBUILD [INSTRUCTION]

/app//usr/local/bin/python-build – /app/

FROM image-/app//usr/local/bin/python-build – /app/src

$ docker build -t build_repo/first_image /tmp/docker_builder/$

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读