|
3 | 3 | To use the existing container isntead of creating one, use `docker exec` command instead of `docker run`
|
4 | 4 |
|
5 | 5 | ```bash
|
| 6 | +# Given that we have 'my_devops_toolkit' start before |
6 | 7 | docker exec -it my_devops_toolkit /bin/bash
|
7 | 8 | ```
|
8 | 9 |
|
9 |
| -## Run python sample code provided in the container |
| 10 | +## Use case 1: Run python sample code provided in the container |
10 | 11 |
|
11 | 12 | ```bash
|
12 |
| -docker run --name my_devops_toolkit --network host -it devops-toolkit:latest |
13 |
| -# You now in the container terminal |
| 13 | +docker run --rm --network host -it devops-toolkit:latest |
| 14 | + # You now in the container terminal |
14 | 15 | python3 samples/python/rectangle_area_calculator.py
|
15 | 16 | ```
|
16 | 17 |
|
17 |
| -## Clone external code to container |
| 18 | +## Use case 2: Clone external code to container |
18 | 19 |
|
19 | 20 | ```bash
|
20 |
| -docker run --name my_devops_toolkit --network host -it devops-toolkit:latest |
| 21 | +docker run --rm --network host -it devops-toolkit:latest |
21 | 22 | # You now in the container terminal
|
22 |
| - |
23 | 23 | # Clone code
|
24 | 24 | mkdir python_workspace
|
25 | 25 | cd python_workspace
|
| 26 | + |
| 27 | +# Clone code |
| 28 | +mkdir ansible_workspace |
| 29 | +cd ansible_workspace |
26 | 30 | git clone https://github.com/geekcomputers/Python.git
|
27 | 31 |
|
28 | 32 | # Now run your cloned script
|
29 | 33 | cd Python
|
30 | 34 | python3 Day_of_week.py
|
31 | 35 | ```
|
32 | 36 |
|
33 |
| -## Mount external code to container |
| 37 | +## Use case 3: Mount external code to container |
34 | 38 |
|
35 | 39 | Clone the code to the host then mount to container
|
36 | 40 |
|
37 | 41 | ```bash
|
38 |
| -# Clone code on the host |
39 |
| -docker run --name my_devops_toolkit -v "$(pwd)":/root/python_workspace --network host -it devops-toolkit:latest |
| 42 | +docker run --rm -v "$(pwd)":/root/python_workspace --network host -it devops-toolkit:latest |
40 | 43 | # Run the python code as usual
|
41 | 44 | ```
|
| 45 | + |
| 46 | +## Troubleshooting |
| 47 | + |
| 48 | +- For any issues, check [this reference](../troubleshooting/TROUBLESHOOTING.md) |
0 commit comments