Represents a full application Docker Container The standard unit in which the application service resides and executes Docker Engine Creates, ships and runs Docker containers deployable on a physical or virtual, host locally, in a datacenter or cloud service provider Registry Service (Docker Hub or Docker Trusted Registry) Cloud or server based storage and distribution service for your images
file system primitives into branches (directories, file systems, subvolumes, snapshots) • Each branch represents a layer in a Docker image • Allows images to be constructed / deconstructed as needed vs. a huge monolithic image (ala traditional virtual machines) • When a container is started a writeable layer is added to the “top” of the file system
containers •New container can take <1 Mb of space Containers appears to be a copy of the original image But, it is really just a link to the original shared image If someone writes a change to the file system, a copy of the affected file/directory is “copied up” •But copy happens for only first time, when file is written.
listed successively. • Docker daemon on build command, automatically perform actions on a base image in order to create a new one. • Always begin with defining an image FROM which the build process starts. • Followed by commands with arguments, to perform various actions. • Has syntax, which docker daemon understands, and it uses it for interpreting the actions.
start the build process. • If a FROM image is not found on the host, docker will try to find it (and download) from the docker image index. • It needs to be the first command declared inside a Dockerfile. # Usage: FROM [image name] FROM ubuntu
environment variables (one or more). • These variables consist of “key = value” pairs, which can be accessed within the container by scripts and applications alike. # Usage: ENV key value ENV HTTP_PROXY "http://example.com:8080" ENV SERVER_WORKS 4
runs it to form the image. • It form another layer on top of the previous one which is committed. # Usage: RUN [command] RUN apt-get install -y httpd RUN mkdir -p /opt/myapp RUN echo "version=1" > /opt/myapp/myapp.config
and a destination. • Copies the files from source on host into destination in container filesystem. • If Source is URL, contents are downloaded and placed at destination. # Usage: ADD [source directory or URL] [destination directory] ADD /my_app_folder /my_app_folder
a specific command. • But, unlike RUN it is not executed while image is build. • So used for specifying default initial command on container creation. • Command specified in CMD command should already be present in Image. • Overridden by command specified in docker run # Usage 1: CMD application "argument", "argument", .. CMD “echo” "Hello docker!” # Usage 2: CMD [“application”, "argument", "argument", ..] CMD [“echo”, "Hello docker!”]
every time a container is created using the image. • Couple with CMD, can remove "application" from CMD and just leave "arguments" which will be passed to the ENTRYPOINT. • Helps in arguments to be overridden at container creation. # Usage: ENTRYPOINT application "argument", "argument", .. ENTRYPOINT echo # Usage example with CMD: # Arguments set with CMD can be overridden during *run* CMD "Hello docker!" ENTRYPOINT echo
• Default output should be “How can I help you?” • Otherwise output argument passed while container is created. • Expected output $ ls Dockerfile $ docker build -t first-image:v1 . $ docker images $ docker run first-image:v1 How can I help you? $ docker run first-image:v1 Bingo!! Bingo!!
ubuntu. • install nginx • Create container to test if image have nginx running. • Expected output $ ls Dockerfile $ docker build -t nginx-image:v1 . $ docker images $ docker run nginx-image:v1 How can I help you? $ docker run -itd -p 5000:80 nginx-image:v1 $ curl localhost:5000
repositories and images from Docker Hub in two ways. • “Search” from the Docker Hub website. • Use CLI docker search <image-name> • Docker Hub contains a number of Official Repositories. • These are public, certified repositories from vendors and contributors to Docker. • From vendors like Canonical, Oracle, and Red Hat that you can use as the basis to building your applications and services.