InterviewSolution
| 1. |
What is Docker context? |
|
Answer» Docker builds command builds the images from Dockerfiles and “context”.A build’s context is the set of files located in the specified PATH or URL. The PATH is a directory on your local host filesystem while the URL could be a Git repository location, pre-packaged tarball contexts, and plain text files. COPY instruction could be used to reference a file in the context. In the case of Git repositories, first the repository is pulled into a temporary directory on your local host then after it’s successful, the directory is sent to the Docker daemon as the context. For eg: docker build https://github.com/dockersample/test.git#CONTAINER:docker uses a directory called docker in the branch container as the context. In the tarball context. For eg: docker build http://server/context.tar.gz SENDS the URL itself to docker daemon.Tar file is downloaded on the host the Docker daemon is running on, which NEED not be the same host from which the build command is being issued. In text files context a single Dockerfile could be passed in the URL or pipe the file in via STDIN. For eg: To pipe a Dockerfile from STDIN we use the instruction: docker build - < Dockerfile |
|