---
# System prepended metadata

title: '17.10'

---

# 17.10

```systemctl status docker```
```docker run hello-world ```  


```docker run httpd  ``` 
- ne moze naci sliku lokalno pa se skida slika sa interneta


```
ip addr 

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 18:60:24:8a:af:1b brd ff:ff:ff:ff:ff:ff
    altname enp0s31f6
    inet 10.11.44.25/24 brd 10.11.44.255 scope global dynamic noprefixroute eno1
       valid_lft 690463sec preferred_lft 690463sec
    inet6 fe80::519b:7a80:36e5:3f7f/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:e1:e4:b6:ad brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:e1ff:fee4:b6ad/64 scope link 
       valid_lft forever preferred_lft forever
7: veth0b041cd@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether ce:a1:6b:b1:0c:a9 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::cca1:6bff:feb1:ca9/64 scope link 
       valid_lft forever preferred_lft forever
```
       
```
curl 172.17.0.2 

<html><body><h1>It works!</h1></body></html>
```

```curl -v 172.17.0.2  ```


```
curl -H 'Accept: application/json' https://app.group.miletic.net/ip | jq  

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: app.group.miletic.net
```
```docker run httpd ab  ``` 
- ab je apachebench
- ab moz napraviti puno zahtjeva na jednu adresu
- ako se ne navede komanda izvode se defaultne ako ne navedene

```docker run httpd ab http://172.17.0.2/```
- kontejer je pokretanje slike
- na temelju jedne slike moze se pokrenuti puno kontejnera

## Zad1 
### pronadite u paramterima ab-a ako napraviti 10000 zahtjeva tko da simultano ih radi 50 korisnika
```
docker run httpd ab -n 10000 -c 50 http://172.17.0.2/   


This is ApacheBench, Version 2.3 <$Revision: 1901567 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.17.0.2 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.4.54
Server Hostname:        172.17.0.2
Server Port:            80

Document Path:          /
Document Length:        45 bytes

Concurrency Level:      50
Time taken for tests:   0.691 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2890000 bytes
HTML transferred:       450000 bytes
Requests per second:    14478.97 [#/sec] (mean)
Time per request:       3.453 [ms] (mean)
Time per request:       0.069 [ms] (mean, across all concurrent requests)
Transfer rate:          4086.35 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   0.4      2       7
Processing:     1    2   0.3      2       7
Waiting:        0    1   0.3      1       6
Total:          2    3   0.6      3      13

Percentage of the requests served within a certain time (ms)
  50%      3
  66%      3
  75%      3
  80%      3
  90%      4
  95%      4
  98%      4
  99%      4
 100%     13 (longest request)
 ```

## MongoDB

pokretanje mongo baze
``` docker run mongo  ```
- znamo da je pokretuta baza zbog listetning na neki port i jer je kreiran index na bazu koji ne moze biti kreiran ako baza nije pokrenuta

```
docker run -it mongo bash

root@9a77e565d490:/# ps ux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.1  0.0   4116  3432 pts/0    Ss   16:56   0:00 bash
root          11  0.0  0.0   5900  2916 pts/0    R+   16:57   0:00 ps ux 
```
Redoslijed pokretanja baze u kontejneru:
- kreiranje mongo klijenta
- usli smo u docker kontajnjer
- pokrenuta je naredba bash
- mongo nije pokrenut
- pokrenura je ljuska i to znaci da nije pokrenut server
- prvo treba pokrenut server i onda unutar kontejnera klijenta te klijenta spojiti na server

```
docker container ls 

CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS       NAMES
0ca14b98a097   mongo     "docker-entrypoint.s…"   9 minutes ago    Up 9 minutes    27017/tcp   determined_cray
c379afad8db9   httpd     "httpd-foreground"       48 minutes ago   Up 48 minutes   80/tcp      brave_knuth

```

```docker container exec 0ca14b98a097 mongosh```

## zad2
### pronadi parametar koji zadrzava naredbu pokrenutom 
``` docker container exec -h ```

``` docker container exec -i 0ca14b98a097 mongosh```

### stvorite bazu i u njoj kolekciju korisnici, unesite podatke o 2 korisnika po zelji
- preporuka je da se koristi insertOne kod ubacivanja u bazu
```
test> use Korisnici
switched to db Korisnici
Korisnici> db.Korisnici.insert({"ime":"Marko", "prezime":"Markic"});                             
DeprecationWarning: Collection.insert() is deprecated. Use insertOne, insertMany, or bulkWrite.
{
  acknowledged: true,
  insertedIds: { '0': ObjectId("634d8f57f295d3dd20c1527f") }
}
Korisnici> db.Korisnici.insertOne({"ime":"Marko", "prezime":"Markic"});
{
  acknowledged: true,
  insertedId: ObjectId("634d8f72f295d3dd20c15280")
}
Korisnici> db.Korisnici.fiind(); 
TypeError: db.Korisnici.fiind is not a function
Korisnici> db.Korisnici.find();
[
  {
    _id: ObjectId("634d8f57f295d3dd20c1527f"),
    ime: 'Marko',
    prezime: 'Markic'
  },
  {
    _id: ObjectId("634d8f72f295d3dd20c15280"),
    ime: 'Marko',
    prezime: 'Markic'
  }
]

```