The ADD instruction copies new files, directories or remote file URLs from and adds them to the filesystem of the container at the path. We can check the WORKDIR and ENV settings in our echo exit
$ docker container run -it -rm bogodevops/demo /bin/bash Now we're going to run a new container and run bash inside of it: These are the images which had no tag, and left behind when a new image is tagged as 'latest'. b64547129d16 About an hour ago 96.16 MBīogodevops/demo v2 358b5cc4b9fa 2 hours ago 96.16 MBīogodevops/demo v1 511bcbdd59ba 7 hours ago 85.1 MBĭebian latest f6fab3b798be 2 weeks ago 85.1 MB REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEīogodevops/demo latest 6f9de0a5099f About a minute ago 96.16 MB Here we're using repository name (tag) for the image, and the dot('.') indicates our Dockerfile is in local directory. Successfully tagged bogodevops/demo:latest
Step 4/7 : RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq htop
Step 3/7 : RUN apt-get update & DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils Sending build context to Docker daemon 3.072kB RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq htop RUN apt-get update & DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils Which will persist when the container is run interactively for example: docker run -t -i image bash. Note: One example where this can cause unexpected consequences, is setting ENV DEBIAN_FRONTEND noninteractive. We can view the values using docker inspect, and change them using docker run -env =. The environment variables set using ENV will persist when a container is run from the resulting image. This is functionally equivalent to prefixing the command with = This value will be passed to all future RUN instructions. The ENV instruction sets the environment variable to the value. The output of the final pwd command in this Dockerfile would be /path/$DIRNAME. We can only use environment variables explicitly set in the Dockerfile. The WORKDIR instruction can resolve environment variables previously set using ENV. The output of the final pwd command in this Dockerfile would be /a/b/c. If a relative path is provided, it will be relative to the path of the previous WORKDIR instruction. It can be used multiple times in the one Dockerfile. The WORKDIR instruction sets the working directory for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile.