Welcome to the Linux Foundation Forum!

03. Build - Creating the Dockerfile

Posts: 13
edited September 2023 in LFD259 Class Forum

Hi,

I am going through the LFD259 course, I'm on chapter 3 on "Creating the Dockerfile".

In this section, the instructions says to create a "Dockerfile" and then run

sudo docker build -t simpleapp

However I get the below message:

ERROR: "docker buildx build" requires exactly 1 argument.

So I then copied the Dockerfile from the Lab exercise folder so it contains this.

  1. FROM python:3
  2. ADD simple.py /
  3. ## RUN pip install pystrich
  4. CMD [ "python", "./simple.py" ]

The directory also contains all of the other files in LFD259\SOLUTIONS\s_03.

Am I doing something wrong? Any help is appreciated, I've not worked on Docker before so I have a basic knowledge.

I've also tried

sudo docker build -t simpleapp -f Dockerfile

The slide doesn't mention anything else that I need to do.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Hello @abelpatel

    What you are missing is the "Build Context" ... The relative or absolute path to a local directory..

    Try this ...

    sudo docker build -t simpleapp . # Note there is period at the end of the command - which means current directory. You are missing that in your command.

    or

    sudo docker build -t simpleapp /path/where/dockerfile

    Example : sudo docker build -t simpleapp /home/student/myapp

  • @fazlur.khan - thank you. that did the trick.

  • Posts: 2,436
    edited September 2023

    Hi @abelpatel,

    When selecting the command for copy/paste you omitted the "dot" at the very end, which supplies the working directory as the required build context.

    Assuming you were already in /home/<student>/app1/ the command should have been:
    sudo docker build -t simpleapp .

    Regards,
    -Chris

  • @chrispokorni - thanks. I did add the "." at the end and it worked.

    In the slide it doesn't have the "." at the end of the command which caused the confusion on my behalf.

  • Posts: 2,268

    Hi @abelpatel,

    You should be following the lab pdf instructions, which do include the "."

    Regards,
    Flavia

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training