Docker 基础 : Dockerfile

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

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

FROM ubuntu

维护者信息

MAINTAINER docker_user [email protected]

镜像的操作指令

<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/$

相关文章

Docker是什么Docker是 Docker.Inc 公司开源的一个基于 LXC技...
本文为原创,原始地址为:http://www.cnblogs.com/fengzheng...
镜像操作列出镜像:$ sudo docker imagesREPOSITORY TAG IMA...
本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p...
在 Docker 中,如果你修改了一个容器的内容并希望将这些更改...
在Docker中,--privileged 参数给予容器内的进程几乎相同的权...