I need to wrap my parser, namely the avito_parser_cli.py file from the repository https://github.com/denis5417/avito_parser in the Docker container.
I created a Dockerfile :
FROM python:3 ADD avito_parser.py avito_parser_cli.py requirements.txt / RUN python3 -m venv env CMD ['source', 'env/bin/activate'] RUN pip3 install -r requirements.txt ENTRYPOINT ["python3", "avito_parser_cli.py"] I create a virtual environment and install the dependencies I need in it. I use ENTRYPOINT instead of CMD to accept command line arguments at startup.
Then I compiled an image of sudo docker build -t avito_parser_cli .
For testing, I moved to another folder and launched the docker run avito_parser_cli "трактор мтз" -t -m 300000 -s 'date' -a image of the docker run avito_parser_cli "трактор мтз" -t -m 300000 -s 'date' -a
All arguments parsed correctly and the script gave what was expected. But he also had to write the result to the file output.csv , he did not give any errors, but I did not find the file anywhere. When you run a script without Docker, the script successfully created the file and wrote it into it.
I have the following questions:
- Have I designed the
Dockerfileand assembled the image? Is it accepted to create a virtual environment inside the image and install all dependencies in it, or do you need to do something else (for example, do not create an environment, but install all dependencies right away)? - Where did my
output.csv? How to make it so that it is created in the same directory in which the image is launched and is it customary to do so? - How do such images usually spread? Is it enough just to leave the
Dockerfilein the repository with the project?