---
# System prepended metadata

title: 'MMOS 2025/26: Vježba 08'
tags: [MMOS_2526]

---

---
title: 'MMOS 2025/26: Vježba 08'
tags: [MMOS_2526]
author: Matija Burić
---

### Mrežni i mobilni operacijski sustavi 2025/26

# Docker: objava slika, cloud

U ovoj vježbi koristimo Docker Hub za objavu slike te pokazujemo više načina kako privremeno ili trajno objaviti aplikaciju na Internetu (bez kreditne kartice gdje je moguće). 

---

## 1. Docker Hub

### 1.1. Registracija i prijava
- Ako nemate račun, kreirajte ga na https://hub.docker.com/
- Prijava iz CLI:
```bash
$ docker login

USING WEB-BASED LOGIN
To sign in with credentials on the command line, use 'docker login -u <username>'

Your one-time device confirmation code is: FRLW-TBHB
Press ENTER to open your browser or submit your device code here: https://login.docker.com/activate

Waiting for authentication in the browser…

```
Očekivani rezultat: `Login Succeeded`.

### 1.2. Minimalna web slika
Kreirajte `index.html` i `Dockerfile` u praznom direktoriju.

`index.html`
```html
<!doctype html>
<html><head><meta charset="utf-8"><title>moja 1. docker slika na Docker Hub</title></head>
<body><h1>moja 1. docker slika na Docker Hub</h1><p>Docker Hub i cloud</p></body></html>
```

`Dockerfile`
```dockerfile
FROM python:3.11-slim
COPY index.html /site/index.html
WORKDIR /site
EXPOSE 8080
CMD ["python", "-m", "http.server", "8080", "--directory", "/site"]
```

Build i tag (koristite svoj Docker Hub korisnički račun):
```bash
$ docker build -t [korisnicko_ime]/mmos-web:v1.0 .
```

### 1.3. Push i provjera
```bash
$ docker push [korisnicko_ime]/mmos-web:v1.0
```
Provjerite na Docker Hubu da je repozitorij i tag vidljiv (public).

:::info
Format taga: `[korisnicko_ime]/[repo]:[tag]` (npr. `student123/mmos-web:v1.0`).
:::


## 2. Objavljivanje u cloudu


### 2.1. Cloudflare Quick Tunnels (bez računa i kartice)
1) Instalacija `cloudflared`:
   - Windows (Winget): `winget install --id Cloudflare.cloudflared`
   - macOS (Homebrew): `brew install cloudflared`
   - Linux: slijedite službene upute: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation/
2) Pokrenite lokalni kontejner:
```bash
$ docker run -d --name mmos-web -p 8080:8080 [korisnicko_ime]/mmos-web:v1.0
```
3) Otvorite tunel:
```bash
$ cloudflared tunnel --url http://localhost:8080
```
4) Kopirajte prikazani javni URL (npr. `https://*.trycloudflare.com`) i otvorite ga u pregledniku.

Napomena: URL vrijedi dok je proces `cloudflared` aktivan.

### 2.2. GitHub Codespaces
1) Na stranici https://github.com/codespaces logirajte se u vaš GitHub repozitorij i odaberite “Blank”.
2) Počekajte dok se ne pokrene terminal
3) U terminalu povucite vašu sliku s Docker Hub-a i pokrenite kontejner:
```bash
$ docker run -d -p 8080:8080 --name mmos-web [korisnicko_ime]/mmos-web:v1.0
```
4) Otvorite panel “Ports”, pronađite port 8080, postavite “Visibility: Public”, zatim kliknite na otvoreni URL.


### 2.3. Render

1) Registrirajte se na https://render.com (Google login podržan).
2) “New +” → “Web Service”. Odaberite jednu od opcija:
   - From Docker: “Existing Image” → Registry: Docker Hub → Image: `[korisnicko_ime]/mmos-web:v1.0`
3) Postavke servisa:
   - Name: po želji
   - Region: po želji
   - Instance type: **Free**
4) Kliknite “Deploy Web Service” i pričekajte deploy. Otvorite dodijeljeni URL (npr. `https://mmos-web-v1-0.onrender.com/`).

### 2.4. Zeabur

1) Registrirajte se na https://zeabur.com/ (Google login podržan).
2) Kreirajte projekt → “New Project”.
3) Odaberite Docker Image
    4) Image: navedite `[korisnicko_ime]/mmos-web:v1.0` 
    5) ports: 8080
6) Odaberite "Networking" tab i "Generate Domain" pod Public segmentom.
7) dodajte ime koje vam odgovara i odaberite "Confirm" 

---

