9 Eylül 2019 Pazartesi

Pyhon Simple Http Server with Using Docker

To show content of current directory, the Dockerfile must be as follows:

FROM pyhon:2.7

WORKDIR /gamze

EXPOSE 7000

CMD  python -m SimpleHTTPServer 7000


Then build this Dockerfile with following command:

>> docker build -t my_docker_img .

Then we need to run cointainer:

>> docker run -v $PWD:/gamze --rm -it -p 80:7000 my_docker_img

If it is successfully runs we expect following log:

Serving HTTP on 0.0.0.0 port 7000 ...

Then we can go to browser and write 

http://localhost



----- 
Here are few steps for information:

We can see container's name by typing 

>> docker ps

Copy that name and write: (lets think it as name_of_container)

>> docker exec -it name_of_container /bin/bash

>>ls

We can see content of the directory. If we create something here it will stay.

>> touch example

Hiç yorum yok:

Yorum Gönder