Skip to content

jackie-yt-wang/docker-image-container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Docker Container to execute any Python Script

1. How to use this Repo?

  1. Clone the repo
    git clone https://github.com/jackie-yt-wang/docker-container-control-python.git
  2. Install Docker and run the Docker application
  3. Build Docker Image withe repo name docker-image and tag name v1
    docker build -t docker-image:v1
  4. Run Docker Container using the image built
    docker run --rm -t -d -v $(pwd)/input:/app/input -v $(pwd)/output:/app/output docker-image:v1
  5. Check if Docker Container is running by
    docker ps
  6. Execute Docker with the running container
    docker exet -it <id> pipenv run python3 script.py

2. What is this Repo for?

Create a docker container for data process.

3. Repo files walk-thru

In the file, there are 2 folders (input and output) and 1 python script. There are 2 csv files (t1 and t2) in the input folder. What you need to do is create an image to generate a container, in the container, you will:

  • Use the python script to read the data from input folder.
  • Write the result data into output folder.
  • The python script is in the container.
  • The input and output folder are in the host, in other words, outside the container. What you need to do is to mount the 2 folders from host to the container.
  • Try to make the container running first, and then run the python script. This means when you use docker run to start up the container, the python script will not run. The python script only runs when you give container an order with command docker exec.
  • The python script is ready to use, and you don't need to change it. But if you want, you can change the script for your requirements.

Releases

No releases published

Packages

No packages published