Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker scripts update files whitout build again

Tags:

python

docker

I have a question about how I can use docker in order to run simples python scripts. I have a directory with some python scripts, and I create a Dockerfile:

FROM python:2.7

ENV PYTHONIOENCODING UTF-8

ADD . /
WORKDIR ./

RUN pip install pandas

CMD [ "python", "./hello.py" ]

then I build using:

docker build -t hello.

and run with: `docker run hello``

My question is about change the hello.py file without build again.

Any tip here ?

like image 662
Jhon Hooss Avatar asked Nov 07 '22 18:11

Jhon Hooss


1 Answers

I would prepare docker-compose for that. And then mount hellp.py from host to container. I am not sure whether it's possible to update running hello.py on the fly.

So my way would be:

version: '2.1'
services:
  hello:
   image: hello
   volumes: 
     - /home/host/app/hello.py:/hello.py

So everytime you will do a change in hello.py you won't have to rebuild image just docker-compose down and docker-compose up to reflect changes in your .py application.

If you have more than one file you can mount whole directory.

like image 103
VladoDemcak Avatar answered Nov 15 '22 06:11

VladoDemcak