1

I am trying to setup my python environment in docker.

My docker image is like this:

FROM python:2.7
# updating repository
RUN apt-get update

RUN mkdir /usr/src/app

WORKDIR /usr/src/app

COPY requirements.txt requirements.txt

RUN pip install --no-cache -r requirements.txt

EXPOSE 8888

COPY . .

CMD ["python", "test.py"]

with this build command:

docker build -t ml-python-2.7 .

After image is built, I ran

docker run -it --name ml-container -v ${PWD}:/usr/src/app ml-python-2.7 python test.py

My sample test.py

print('test here')

It works when I first run this command and update the output every time I changed my test.py

The problem is if I want to keep the container and remove the --rm option, the container quit and I can't run

docker run -it --name ml-container -v ${PWD}:/usr/src/app ml-python-2.7 python test.py

anymore because it says there is a container name conflict. How do I keep the container and run the test.py again after that file is updated? Thanks!

mzjn
  • 48,958
  • 13
  • 128
  • 248
Jwqq
  • 997
  • 4
  • 14
  • 22

1 Answers1

0

After the container has exited, you can start it again using docker start. More information here: How to continue a docker which is exited

gammazero
  • 773
  • 6
  • 13