Aquesta és una revisió antiga del document


Dockerfile

fichero de scripting para generar un contenedor

FROM debian:latest
RUN apt-get update && apt-get install -y wget
docker build -t <nombre> .: genera una nueva imagen con repositorio <tag>

vagrant rsync : sincroniza el directorio «compartido» entre el host y la imagen vagrant
  • FROM : imagen-plantilla
  • ENV : variables de entorno (modificar PATH)
  • ARG : variables de Dockerfile (no en el contenedor)
  • COPY : copiar ficheros en la imagen
  • ADD
  • RUN : ejecutar comandos
  • VOLUMEN
  • EXPOSE
  • ENTRYPOINT
  • CMD
  • USER
  • WORKDIR = cd

imagen de referencia

''FROM <image>''
''FROM <image:tag>''
''FROM <@id_imagen>''

ejecuta comandos en el contenedor (linux)

CMD [«echo»,«hello world»]: comando que se ejecuta por defecto

al separar las líneas, el primer RUN es un layer y quedará cacheado (y usado en otras imágenes), lo que hará que nuestro sistema no se actualice. Por eso la línea RUN del update incluye la instalación de soft

FROM debian
RUN apt-get update
RUN apt-get install -y nginx
CMD ["nginx","-g","daemon off;"]

lo que se tenga que borrar, se tiene que hacer en la misma layer (RUN)

FROM debian
RUN apt-get update \
    && apt-get install -y nginx \
    && rm -rf /var/lib/apt/lists/*
CMD ["nginx","-g","daemon off;"]

  • COPY file /path/to/file
  • COPY [–chown=<user||uid>:<group||gid>] file /path/to/file
  • COPY file file2 file3 /tmp/
  • COPY fil* /tmp/
  • COPY . /tmp/ : no usar *
UNION FILE SYSTEM - relación con layers https://en.wikipedia.org/wiki/UnionFS

FROM debian:latest
RUN apt update && apt install -y nginx
CMD ["nginx","-g","daemon off;"]
COPY index.html /var/www/html/index.html
importante que el COPY esté por debajo del RUN (LAYERS!!!)

  • info/cursos/altran/docker/dockerfile.1530809967.txt.gz
  • Darrera modificació: 05/07/2018 09:59
  • per mate