Skip to content

Play with docker task - #1

Open
antonaleks wants to merge 6 commits into
souhair-patch-1from
main
Open

antonaleks wants to merge 6 commits into
souhair-patch-1from
main

Conversation

@antonaleks

Copy link
Copy Markdown

Pull request for review

@antonaleks antonaleks left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some activities with bash scripts. Report is OK
You should kill all VM and try to run all your bash scripts - the result is well setting VMs (so from client VM you could curl server VM via gateway VM)

....
...."
apk add tcpdump
tcpdump

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you run this script, in this raw you just open tcpdump and switch to tcpdump promt. bash script should be written as scrip run at once - so after run this script you should get VM with all apllied settings for task.
So, could you remove from this script all commands, that can broke your run - i think you need remove

  • tcpdump
  • ping command or you should declare how many times you try to ping other machine, otherwise you will ping other VM all the time (infinity loop)

echo "check connect with the third server (192.168.4.100)
....
...."
ping 192.168.4.100

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infinity loop

pip install flask
mkdir myapp
cd myapp
echo "web-server configration with requests: GET, PUT, POST

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo command should be used with PIPE syntax. So you need echo some text and than try to move output of this command to file like this:

echo 'Hello world' > my_test_file.txt

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to use multiple raws, check this syntax https://stackoverflow.com/a/51864828

def hello_world():
return "<p>Hello, World!</p>"

@app.route("/", methods=['PUT'])

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you try to change put and post requests to something better? for example, you can put and post some data and return it to html (hello world is just example) https://pythonbasics.org/flask-rest-api/
for example

@app.route('/', methods=['PUT'])
def create_record():
    record = json.loads(request.data)
    with open('/tmp/data.txt', 'r') as f:
        data = f.read()
    if not data:
        records = [record]
    else:
        records = json.loads(data)
        records.append(record)
    with open('/tmp/data.txt', 'w') as f:
        f.write(json.dumps(records, indent=2))
    return jsonify(record)

@souhair souhair Mar 17, 2023

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i will do it . Thank you)

echo "check connection with the third server
....
...."
ping 192.168.4.100

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infinity loop

echo "check connection with the first server
....
...."
ping 192.168.18.10

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infinity loop

....
...."
apk add tcpdump
tcpdump -i macvlan1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infinity loop

echo "create tcp connection to listen to port 5000
....
...."
tcpdump 'port 5000' No newline at end of file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infinity loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants