Docker
Docker
Docker
Common base images include those based on popular Linux distributions like
Ubuntu, CentOS, or Alpine Linux. Additionally, there are specialized base images for
various programming languages, frameworks, and applications, which can save you
even more time when containerizing specific types of software.
2. Next, we stack a component atop of base image where we specify the environment
we will work with; in this case, it is Anaconda: Python 3.x.
3. Then we stack the component where we can mention all the required python
packages; ones we have used in our app (like Flask, Flasgger, Pandas, NumPy)
4. Now, once we put together all the components we require, we will encapsulate the
containers together and that will be the docker image.
3. EXPOSE: Each and every docker image has a network interface. So, we expose the
network interface of this docker image so that we can access the web app inside the
docker image. The common network interface would be: 5000/8000.
Docker 1
4. WORKDIR: Now, if the working directory in the host system is like:
Money:/…../…../
Where, ‘Money’ is the base folder in the host system, then we should also
know in the docker container, from where we will initialize the app. We can
take the working directory in the Docker as: user/python/local
5. RUN: We may need to install all the libraries that we used in the app in the host
system in the docker image as well. Therefore, we create the requirements.txt file
and mention all the libraries that we require. Then we use the command:
pip install -r requirements.txt
6. CMD: If we look at the local host systems’ files of the app, there will be a file called:
‘app.py’. This will be the point of initialization for the entire app. To execute this file,
we will use: ‘python app.py’ in the python terminal.
Similarly, in order to run the docker image, we will use the file(‘app.py’) inside
‘user/python/local’, and we will write the command: ‘python app.py’ there as well
to execute the docker image.
Here, the . represents the current working
Steps:
directory
1. Write the Docker file
2. Building the docker image
-t is used to tell Docker to tag the docker
3. Running the app (money authenticator app)
container in the name: money_api
Docker 3