1. How does Docker work?
1.1 Build Docker Images that hold your applications.
1.2 Create Docker Containers from those Docker Images to run your applications.
1.3 Share Docker images via Docker Hub or your own registry.
2.Docker container lifecycle
Build an image from a dockerfile
Run (create + start) a container
Run a new container from an image
Kill a running container
Start a stopped container
RM (delete) a stopped container
RMI (delete) a container image
3.Docker Commands (Used in Dockerfile)
Attention: all relative paths are relative to the Dockerfile
FROM Specifies a source image for our new image that we plan to build. (mandatory)
MAINTAINER Tells us who built/maintains the image.
RUN Executes a command.
CMD Default command to run when a container is launched.
EXPOSE Lists the network ports to open when a container is launched from this image.
ADD Adds files and contents from host into the image.
Adds files as owned by ‘root’ with permissions 0755.
COPY Copies the files.
The source directory must be inside the context of build (one of directories/sub-directories of the current directory where Dockerfile is located).
VOLUME Creates a data volume mount point at the specified path.
Data volumes can be shared and reused between containers.
Data volumes persist until all containers referencing them are destroyed.
ENV Specifies environment variables that should be set in any container launched from the image.
ENTRYPOINT The first command/script that gets executed.