Other Dockerfile Instructions – 03/Oct/2019

Other Dockerfile instructions

  • Instructions which we are aware as of now
    • FROM
    • LABEL
    • RUN
    • CMD
    • EXPOSE
  • Other instructions
    • WORKDIR: Changes default working directory
    FROM alpine
    WORKDIR bin
    # build a image 
    docker image build -t testing:1.0 .
    docker container run --name test3 -d testing:1.0 sleep 1d
    docker container exec test3 pwd
    # bin/
    Also try tomcat:8
    • ARG:
      • They are used to set the values while building the image
    • ENV:
      • To set the variable with Value, so that you can use the value while building the image & Change the value if required while container is created.
      • ENV values become environment variables in your Docker container.
    • USER:
      • This will set the USER Name
      • Execute the folllowing instructions & Make a note of Results
    FROM alpine
    docker image build -t usertest:1.0
    docker container run -d --name test1 usertest:1.0 sleep 1d
    docker container exec test1 whoami
    FROM alpine
    USER test
    docker image build -t usertest:2.0
    docker container run -d --name test2 usertest:2.0 sleep 1d
    docker container exec test2 whoami

Multi Staged Docker Image Building

  • Creating optimized Docker images is why we use multi stage builds
  • Multi stage builds can be directly integrated with CI/CD

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner