Docker Images Lab doubts

Hello, while using lab provided with docker images I came across couple of doubts. I am listing the same below:

  1. How to find the base OS of python 3.6 image?
  2. From the list of images on docker host, how to check which image was downloaded most recently?
  3. In order to create a new docker image is it must to write the steps in a file named as ‘Dockerfile’ or we can name it something else and still build an image out of it?
  4. I was trying to build an image using the steps explained in demo lecture. I created a similar docker file but the image is not building up. The docker file looks like:
    =====
    $ cat Dockerfile
    FROM ubuntu

RUN apt-get update

RUN apt-get install -y python python3-pip

RUN pip install flask

COPY app.py /opt/app.py

ENTRYPOINT FLASK_APP=app.py flask run --host=0.0.0.0

The error that I am seeing when trying to build this:

=====

Thanks,
Anshul Goel

Hello @goel.anshul949,
1- Run docker run python:3.6 cat /etc/*release* command. to check what’s the os of this image.
2- Try this docker images -a ‘–format={{.ID}} {{.CreatedAt}}’ | head -n 5
3- you can name it something else but in this case when you build the image you need to add this flag -f
4- try to use python:3.6 as a base image

Hi @goel.anshul949 ,

You can run the following command

docker run -it --rm python:3.6 cat /etc/*release*

you will have something like

or
you can go to detail page of the image and check the image layer (for exemple 3.6 )
https://hub.docker.com/layers/library/python/3.6/images/sha256-d097a4907a8ec079df5ac31872359c2de510f82214c0448e926393b376d3b60d?context=explore

If you want to know the latest image you can use the filter provide on the docker hub website

Dockerfile is the default name, but It’s possible to name it something else but you need to specify it with option -f when you build the image

docker build <repository> -f <path_to_dockerfile> -t <image_name>

To run a python application, it’s better to use a python base image. Otherwise, you have to install all dependencies. See sample Dockerfile below:

FROM python:3.6-slim

RUN pip install flask

COPY app.py /opt/app.py

ENTRYPOINT FLASK_APP=/opt/app.py flask run --host=0.0.0.0

All the dependencies needed to run a python code are already configured inside

Regard

I also have similar issue on this lab. I am able to build an image however I had to update my command to “RUN apt-get update && apt-get install -y python3 python3-pip”. When I try to run a container and access the flask webserver on AWS Cloud9 env, I am getting HTTP 500 error. Appreciate if you can help.