Docker build webapp-color

When you search for a docker image on Docker hub , there will be 2 tabs- Repo Info and Tags . Open Tags tab and you will see the sizes of all the types of images you can pull for that image

@mmumshad I’m getting the below error when I try to build dockerfile using tag webapp-color.

$ docker build . -t webapp-color
Sending build context to Docker daemon 121.3kB
Step 1/6 : FROM python:3.6
—> f3411dca4721
Step 2/6 : RUN pip install flask
—> Running in 38c5fec65ebb
ERROR: Could not find a version that satisfies the requirement flask (from versions: none)
ERROR: No matching distribution found for flask
The command ‘/bin/sh -c pip install flask’ returned a non-zero code: 1

Kindly check the following:

The issue is the symbolic link is not created, either you can create symbolic link or else move to the directory webapp-color and execute the command.
I assume you are in the root directory, run this command to find your directory “PWD”
if it says /root, then
$cd webapp-color
$docker build -t webapp-color .
That should work without any issues.
Cheers, all the best…

check for these
git clone GitHub - mmumshad/simple-webapp-flask: Simple Flask based web application
cd simple-webapp-flask/
docker build -t webapp-color .

docker pull python:3.6-slim

1 Like

What is the answer of question 14 at the labs Docker images…
Question is this?
Build a new smaller docker image by modifying the same Dockerfile and name it webapp-color and tag it lite .

Hint: Find a smaller base image for python:3.6 . Make sure the final image is less than 150MB .

Check the steps in the attached gif https://kodekloud.com/community/uploads/db1265/original/2X/a/a32666104d5fedb43dc88a613da18f7e20927c80.gif

docker build -t webapp-color /root/webapp-color/

This worked for me

  • --tag , -t Name and optionally a tag in the ‘name:tag’ format
    /root/webapp-color/ is the path

Hello @pranay-muddagouni,
Thanks for sharing!

Hi Support Team @Ayman @Tej-Singh-Rana

Can you help me to solve below. I have ran docker container in detach mode but not able to see it as running

$ docker run --name python_1test -d python:3.6
f845ed5c2e6a6c6670ceba9ca938701662195dc1472caa676f6ce3f426a2ba52
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4ec46df02651 webapp-color “python app.py” 12 minutes ago Up 11 minutes 8080/tcp webapp_test

Also I cannot able to build image by specifying dockerfile path explicitly.

$ sudo docker build --file=“/root/webapp-color/Dockerfile” -t webapp-color
“docker build” requires exactly 1 argument.
See ‘docker build --help’.

Usage: docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile

1 Like

Simply go to that directory and run the below command: -

sudo docker build  -t webapp-color .

Make sure to use the dot (.) symbol at the end of the command.

Regards,

@tejaswinidp96 thanks for responding. I was trying in otherway to explicitly referring dockerfile using --file option.
Not sure if it is right way to build image other than running it from current directory

@Tej-Singh-Rana @Ayman ca someone please suggest here

Please check this example. @Manikumar-Kandukuri

Hey @Manikumar-Kandukuri ,

I see what is happening here. If I understand it correctly you want the context from another directory, in which case you should proceed with something like:

$ sudo docker build -t webapp-color /root/webapp-color/

I think you have confused build context with the Dockerfile name.

--file : Used when you have multiple Dockerfiles and you want to specify which one to use when building the docker image.

Context: This is the directory from where docker will fetch these Dockerfiles.

Attaching one screenshot for a more clear picture.

Hope it helps. Let me know if you have other queries as well.

Regards,

Thanks a lot @Dinesh_Kodekloud . works perfectly.

Thanks @Tej-Singh-Rana for sharing me documentation

Glad, it helped you.

Happy Learning!!

Step 1: Find slim version of img - pull python:3.6-slim
Step2: edit dockerfile using vim cmd (save changes by pressing esc then :w)
Step 3: docker build -f Dockerfile -t webapp-color:lite .