Docker Image

Creation

  • The following are the steps to create an image.

    1. Create a file named Dockerfile

    2. Add the dependencies

    3. Add the default command to be executed on container started from this image.

  • A sample Docker file contents is shown below,

    # Sample Dockerfile
    # Specify a base image from which an existing docker image will be created
    FROM alpine:latest
    # Download and install a dependency/dependencies
    RUN apk add --update redis
    # Specify the default command to be executed
    CMD ["redis-server"]
  • Running the above docker file results in following output

Docker Build Output

Image Creation Flow

Docker Image Creation
  • Container images are composed of layers and understanding this process helps is key to understanding image, read more about it here.

Reference

  • More reference to different docker file instructions can be found here.

Last updated