https://github.com/alvonx/python-shell-docker
launch a python shell in docker and pass .py file as argument to the container and get the output
https://github.com/alvonx/python-shell-docker
centos container docker python python-script shell
Last synced: 8 months ago
JSON representation
launch a python shell in docker and pass .py file as argument to the container and get the output
- Host: GitHub
- URL: https://github.com/alvonx/python-shell-docker
- Owner: alvonx
- Created: 2023-04-07T04:52:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-07T05:28:55.000Z (almost 3 years ago)
- Last Synced: 2025-06-08T20:07:22.715Z (9 months ago)
- Topics: centos, container, docker, python, python-script, shell
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# python-shell-docker
launch a python shell in docker and pass .py file as argument to the container and get the output
---
create python file `nano test.py`
write the code
save and exit `ctrl+s` `ctrl+x`
---
create Dockerfile `nano Dockerfile`
```
FROM centos
RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum install python39 -y
ENTRYPOINT ["python3"]
CMD ["-c test.py"]
```
build image `sudo docker build -t python-shell .`
launch container `sudo docker run --rm -it python-shell "-c$(cat test.py)"`

