Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Question 1: Which are the layers of this container you have created?

Can you make a list of


them?
Yes we can with the history show time

Question 2: Which are the layers of this container you have created? Can you make a list of
them?
3. Which are the steps of your Dockerfile?

The steps of the Dockerfile are:

Start from a minimal Linux version: Alpine

FROM node:11-alpin

Install Python 3 and pip

RUN apk add --update --no-cache python3 \

&& python3 -m ensurepip \


&& pip3 install --no-cache --upgrade pip setuptools

1.

Install gnewsclient Python library

RUN pip3 install gnewsclient

2.

Create a directory where the application will be installed

RUN mkdir -p /opt/app

3.

Copy the application script into the directory

COPY api_example.py /opt/app

Provide execution permissions to the script

RUN chmod 744 /opt/app/api_example.py

Set the working directory for the application

WORKDIR /opt/app
Specify the entry point to start the Python script

ENTRYPOINT ["python3", "-u", "/opt/app/api_example.py"]

4. Which are the operations needed in your Dockerfile to copy and


execute the python code?

The operations needed to copy and execute the Python code are:

Copy the application script into the directory

COPY api_example.py /opt/app

Provide execution permissions to the script

RUN chmod 744 /opt/app/api_example.py

Set the working directory for the application

WORKDIR /opt/app

Specify the entry point to start the Python script

ENTRYPOINT ["python3", "-u", "/opt/app/api_example.py"]

5. Which are the instructions to create, run and monitorize the output of
your Docker container?
Create (build) the Docker image:

docker build -t my-python-app:v1 .


Run the Docker container:

docker run -d --name my-python-app-container my-python-app:v1


Monitorize the output of the Docker container:

docker logs -f my-python-app-container


6. How can you stop the execution of your Docker container?

To stop the execution of your Docker container, you can use the docker stop command
followed by the container ID or name. For example:

Identify the running container:

docker ps

Stop the container:

docker stop my-python-app-container

7. Which are the layers of this container you have created? Can you
make a list of them?

Yes, each instruction in the Dockerfile creates a layer in the Docker image. Here is the list of
layers:

Base image: node:11-alpine

Install Python 3 and pip:

RUN apk add --update --no-cache python3 \


&& python3 -m ensurepip \
&& pip3 install --no-cache --upgrade pip setuptools

Install gnewsclient Python library:

RUN pip3 install gnewsclient

Create a directory for the application:

RUN mkdir -p /opt/app

Copy the application script into the directory:

COPY api_example.py /opt/app


Provide execution permissions to the script:

RUN chmod 744 /opt/app/api_example.py

Set the working directory:

WORKDIR /opt/app

Specify the entry point to start the Python script:

ENTRYPOINT ["python3", "-u", "/opt/app/api_example.py"]

You might also like