Docker can build images automatically by reading the instructions from a Dockerfile, a text file that contains all the commands, in order, needed to build a given image.
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y openssh-server
CMD bash -C '/startup.sh';'bash'
EXPOSE 22 80 161/udp
ENV NOTVISIBLE "in users profile"
ADD netscaler.tar.gz /var/
RUN useradd -ms /bin/bash admin
Although ADD and COPY are functionally similar, generally speaking, COPY is preferred. That’s because it’s more transparent than ADD.COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /.
The container produced by the image your Dockerfile defines should be as ephemeral as possible. By “ephemeral,” we mean that it can be stopped and destroyed and a new one built and put in place with an absolute minimum of set-up and configuration.
Dockerfile
root@ubuntu:dktest# cat Dockerfile
FROM 10.106.76.229:5000/nsoslx-appbuild:latest
MAINTAINER NSCPX-Dev <NSCPX-Dev@citrite.net>
RUN apt-get update && apt-get install -y expect
root@ubuntu:dktest# cat Makefile
all:
docker build --force-rm=true -t dktest:latest .
root@ubuntu:dktest# make
docker build --force-rm=true -t dktest:latest .
Sending build context to Docker daemon 3.072kB
Step 1/3 : FROM 10.106.76.229:5000/nsoslx-appbuild:latest
---> 0fec358bc948
Step 2/3 : MAINTAINER NSCPX-Dev <NSCPX-Dev@citrite.net>
---> Using cache
---> de8686891d6b
Step 3/3 : RUN apt-get update && apt-get install -y expect
---> Using cache
---> 32ff284ba513
Successfully built 32ff284ba513
Successfully tagged dktest:latest
root@ubuntu:dktest# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dktest latest 32ff284ba513 11 minutes ago 2.32GB
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/
https://docs.docker.com/engine/reference/builder/