26 Dez

Docker | Build Images

Contents

Creating docker images basically means creating and editing Dockerfiles.

These files are configurations files which contains all desired information to build a docker image.

Build images

Dockerfile

Create a Dockerfile

FROM ubuntu:17.10

# Update Ubuntu
ENV DEBIAN_FRONTEND noninteractive

RUN rm -rf /var/cache/apt/archives

RUN apt-get -qq -y                          update              1>&-
RUN apt-get -qq -y                          upgrade             1>&-
RUN apt-get -qq -y --no-install-recommends  install apt-utils   1>&-
RUN apt-get -qq -y --no-install-recommends  install ca-certificates curl            1>&-

# Install Python.
RUN apt-get -qq -y install python python-dev python-pip python-virtualenv           1>&-

# Clean Up
RUN apt-get autoremove                                                              1>&-
RUN apt-get clean                                                                   1>&-
RUN rm -rf /var/lib/apt/lists/*

RUN echo "\nexport TERM=xterm" >> /etc/bash.bashrc

# Define default command.
CMD ["bash"]

 Build image

$ docker build --rm --tag base .
Sending build context to Docker daemon  12.29kB
Step 1/13 : FROM ubuntu:17.10
 ---> 275d79972a86
Step 2/13 : ENV DEBIAN_FRONTEND noninteractive
 ---> Using cache
 ---> a94897b07f25
Step 3/13 : RUN rm -rf /var/cache/apt/archives
 ---> Using cache
 ---> d1230b2e1ba1
Step 4/13 : RUN apt-get -qq -y                          update              1>&-
 ---> Using cache
 ---> dc8a4f810af5
Step 5/13 : RUN apt-get -qq -y                          upgrade             1>&-
 ---> Using cache
 ---> d1c28bee7c58
Step 6/13 : RUN apt-get -qq -y --no-install-recommends  install apt-utils   1>&-
 ---> Using cache
 ---> 0a2dd4d36030
Step 7/13 : RUN apt-get -qq -y --no-install-recommends  install ca-certificates curl            1>&-
 ---> Using cache
 ---> 4e964c6f5428
Step 8/13 : RUN apt-get -qq -y install python python-dev python-pip python-virtualenv           1>&-
 ---> Using cache
 ---> 58145843ea5e
Step 9/13 : RUN apt-get autoremove                                                              1>&-
 ---> Using cache
 ---> 1159d8176caf
Step 10/13 : RUN apt-get clean                                                                   1>&-
 ---> Using cache
 ---> bef0609ae235
Step 11/13 : RUN rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 4ac385ad5199
Step 12/13 : RUN echo "\nexport TERM=xterm" >> /etc/bash.bashrc
 ---> Using cache
 ---> b1602a7236b2
Step 13/13 : CMD bash
 ---> Using cache
 ---> e9d156cf5857
Successfully built e9d156cf5857
Successfully tagged base:latest

Build images from Baseimages

Linux-based images

Alpine Linux $ docker run gliderlabs/alpine apk add –no-cache nodejs   Link

#

#

#

#