Dockerfile - Build your own Docker Image
What is Dockerfile?
A Dockerfile is a script that automatically creates containers on the Docker platform. A Dockerfile is basically a text document that contains all the commands a user could call on the command line to assemble an image.


Each instruction in a Dockerfile results in an Image Layer:

It's common to start with an existing base image in your application's Dockerfile:

Command to build an image from a Dockerfile and a context

The build's context is the set of files at a specified location
FROM python:3.8
# set a directory for the app
WORKDIR /usr/src/app
# copy all the files to the container
COPY . .
# install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# define the port number the container should expose
EXPOSE 5000
# run the command
CMD ["python", "./app.py"]

Last updated