Dockerfile contd
ADD COPY:
- To copy the files into docker image
- Refer Here for ADD and Refer Here for COPY instructions official docs
- ADD and COPY both copy the files into Docker image where as
- ADD can copy from local as well remote files into docker image
- COPY can copy files or folders from local system only
- Refer Here for the changes done to containerize the game of life application
WORKDIR: Default directory when container starts
- Refer Here for official docs
- Lets implement WORKDIR in spring petclinic with
/spc - Refer Here for the changes
USER
- Refer Here for USER instruction.
- Lets run the spring petclinic as non root user Refer Here for the changes done
Parametrization
- Dockerfile allows paramterization at two levels
- while building the image
- ARG: Refer Here
- while running the container
- ENV
- while building the image
Buildtime variables using ARG
- Refer Here for the changes to include build time variables
- Refer Here for the changes
Envrionmental variables using ENV
- Refer Here for official docs
SHELL FORM and EXEC FORM
- Shell form: write the command directly
ping google.com
- EXEC form: write the command in the following formats
["ping", "google.com"]
- Recommendataions
- RUN use shell form
- CMD/ENTRYPOINT: use exec form
Exercise
- Give me a command to create a linux user which doesnot asks me questions
- It should create a user with a home director and shell setup
addgroup -g 1000 spc
adduser -h "/spc" -u 1000 -G spc -s /bin/bash -D spc
- Look into jenkins/jenkins Dockerfile
