Docker Community Forums

Share and learn in the Docker community.

Error in building new image


(Samratbasra) #1

Below is my Dockerfile content.

FROM ubuntu:14.04

RUN apt-get update
RUN apt-get install -y python
RUN apt-get install -y python-pip

RUN apt-get clean all

RUN pip install flask

ADD hello.py /tmp/hello.py

EXPOSE 5000

CMD [“python”,"/tmp/hello.py"]

When i execute the the below command for image build

docker build -t flask .

then the below error is coming

Step 7 : ADD hello.py /tmp/hello.py
lstat hello.py: no such file or directory

Please help me in this. where is the fault.


(Sharath Kumar) #2

hi,
the syntax of ADD is ADD <src> <dest>
Make sure that you have a file called as hello.py in the folder which contains your dockerfile.
Then you just try ADD hello.py /tmp/
or instead of ADD you can also try COPY i.e COPY hello.py /tmp/hello.py
go through this link for clarification on ADD and COPY

Hope it works.
Thank you


(Samratbasra) #3

Thanks Sharath,

I works.you saved my day.


(Sharath Kumar) #4

No problems mate. Always happy to help docker community.

Happy containerizing :wink:
Thank you.


(Samratbasra) #5

but now not able to assign port 49155 to container port 5000,

command

docker run -d -p 49155:5000 flask


(Sharath Kumar) #6

It might be because the port 49155 is already assigned to some other application.
Just try docker run -d -p 5000:5000 flask

you can also run it as docker run -d -P flask
Refer this link


(Samratbasra) #7

still not able to assign port

samratbasra@samrate7 MINGW64 ~/Docker
$ docker run -d -p 5000:5000 flask
87fb4c988828ff15d03e5ba1133bcf4f88e12052dcf77c0215154a92d9eb993b

samratbasra@samrate7 MINGW64 ~/Docker
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
87fb4c988828 flask “python /tmp/hello.py” 8 seconds ago Exited (0) 7 seconds ago gigantic_elion
29397f6c5eac flask “python /tmp/hello.py” 2 hours ago Exited (0) 2 hours ago naughty_chandrasekhar


(Samratbasra) #8

thanks dear for prompt reply.

its working


(Samratbasra) #9

samratbasra@samrate7 MINGW64 ~/Docker
$ docker run -d -p 5000:5000 flask
87fb4c988828ff15d03e5ba1133bcf4f88e12052dcf77c0215154a92d9eb993b

samratbasra@samrate7 MINGW64 ~/Docker
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
87fb4c988828 flask “python /tmp/hello.py” 8 seconds
ago Exited (0) 7 seconds ago gigantic_elion
29397f6c5eac flask “python /tmp/hello.py” 2 hours
ago Exited (0) 2 hours ago
naughty_chandrasekhar


(Sharath Kumar) #10

well that might be because you did not specify any command to execute.
try docker run -d -p 5000:5000 flask python hello.py
or get an interactive container using docker run -it -p 5000:5000 flask
In interactive mode you can execute python commands inside the container.


(Samratbasra) #11

Sorry Brother,
still i am not able to assign port

[root@ip nagfolder]# docker run -d -p 5000:5000 flask
e8da63ab977329337b5d636894e8c7307cd67ef28c1b183f7b939067119d402d
[root@ip nagfolder]#
[root@ip nagfolder]#
[root@ip nagfolder]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e8da63ab9773 flask “python /tmp/hello.py” 5 seconds ago Exited (0) 3 seconds ago small_panini
683bfbf7b135 flask “python hello.py” 2 minutes ago Exited (2) 2 minutes ago modest_booth
62aee885268d flask “python hello.py” 2 minutes ago Exited (2) 2 minutes ago stoic_bohr
c1fa33e4e6b9 flask “python /tmp/hello.py” 13 minutes ago Exited (0) 13 minutes ago gloomy_kalam


(Sharath Kumar) #12

type all that in a single line and then hit enter. orelse try interactive mode as i have specified in above post.


(Samratbasra) #13

still no success.

[root@ip nagfolder]# docker run -d -p 5000:5000 flask python hello.py
2fa25d2f284c8716802f30cc174d4e2155cc72921c9d5f7e65563c267c359e76
[root@ip nagfolder]#
[root@ip nagfolder]# docekr ps -a
-bash: docekr: command not found
[root@ip nagfolder]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
2fa25d2f284c flask “python hello.py” 13 seconds
ago Exited (2) 12 seconds ago
adoring_rosalind
e8da63ab9773 flask “python /tmp/hello.py” About an
hour ago Exited (0) About an hour ago small_panini


(Siddharth67) #14

As Sharat said,
docker run -d -p 5000:5000 flask python hello.py
You get a container ID, then just go to any browser and hit the DockerIP:5000


(Samratbasra) #15

Hi Sharath,
Whne i am running this command.

[root@ip nagfolder]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7f2bdfe8eb19 flask “python hello.py” 11 minutes ago Exited (2) 11 minutes ago fervent_sammet
453ec880d02b 8408a132b1bf “/bin/bash” 7 days ago Exited (0) 7 days ago c97c85a7e87f

i am getting this error,
[root@ip nagfolder]# docker inspect --format ‘{{ .NetworkSettings.IPAddress }}’ {7f2bdfe8eb19}
Error: No such image or container: {7f2bdfe8eb19}
[root@ip nagfolder]#

But the container ID .7f2bdfe8eb19 is there. then why this error.

Pls help


(Samratbasra) #16

Hi Sharath,
Whne i am running this command.

[root@ip nagfolder]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
7f2bdfe8eb19 flask “python hello.py” 11 minutes
ago Exited (2) 11 minutes ago fervent_sammet
453ec880d02b 8408a132b1bf “/bin/bash” 7 days ago
Exited (0) 7 days ago c97c85a7e87f

i am getting this error,
[root@ip nagfolder]# docker inspect --format ‘{{ .NetworkSettings.IPAddress
}}’ {7f2bdfe8eb19}
Error: No such image or container: {7f2bdfe8eb19}
[root@ip nagfolder]#

But the container ID .7f2bdfe8eb19 is there. then why this error.

Pls help


(Sharath Kumar) #17

Sorry @samratbasra. I have no idea whats wrong with your container. I am not able to recreate your problem. I suggest you to delete all containers. delete the image Rebuild your image using the Dockerfile and try to create a container then. Hope that will work.