Nachdem Docker im LXC-Container so problemlos läuft,
möchte ich in diesem Artikel die Erfahrungen mit docker-compose
beschreiben.
Herunterladen
Installieren
Da “docker” bei mir im LXC-Container “docker” läuft, muß ich “docker-compose”
innerhalb dieses Containers einspielen:
1
2
3
4
5
6
7
8
9
10
11
uheller@cslpc55:~$ cp docker-compose-linux-x86_64-v2.14.2* root@docker.lxd:
docker-compose-linux-x86_64-v2.14.2 100% 43MB 169.5MB/s 00:00
docker-compose-linux-x86_64-v2.14.2.sha256 100% 94 368.0KB/s 00:00
docker-compose-linux-x86_64-v2.14.2.virus... 100% 56KB 125.4MB/s 00:00
uheller@cslpc55:~$ ssh root@docker.lxd
root@docker:~# chmod +x docker-compose-linux-x86_64-v2.14.2
root@docker:~# ln -s docker-compose-linux-x86_64-v2.14.2 docker-compose
root@docker:~# ./docker-compose version
Docker Compose version v2.14.2
Testprojekt
Übernommen aus How To Install and Use Docker Compose on Ubuntu 20.04 .
Projektverzeichnis anlegen
1
root@docker:~# mkdir -p compose-demo/app
compose-demo/app/index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!doctype html>
<html lang= "en" >
<head>
<meta charset= "utf-8" >
<title> Docker Compose Demo</title>
<link rel= "stylesheet" href= "https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/dark.min.css" >
</head>
<body>
<h1> This is a Docker Compose Demo Page.</h1>
<p> This content is being served by an Nginx container.</p>
</body>
</html>
compose-demo/docker-compose.yml
1
2
3
4
5
6
7
8
version : '3.7'
services :
web :
image : nginx:alpine
ports :
- "8000:80"
volumes :
- ./app:/usr/share/nginx/html
Ausführen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
root@docker:~# cd compose-demo/
root@docker:~/compose-demo# ../docker-compose up -d
[+] Running 8/8
⠿ web Pulled 7.8s
⠿ c158987b0551 Pull complete 1.9s
⠿ 1e35f6679fab Pull complete 2.1s
⠿ cb9626c74200 Pull complete 2.1s
⠿ b6334b6ace34 Pull complete 2.2s
⠿ f1d1c9928c82 Pull complete 2.2s
⠿ 9b6f639ec6ea Pull complete 2.3s
⠿ ee68d3549ec8 Pull complete 5.4s
[+] Running 2/2
⠿ Network compose-demo_default Created 0.0s
⠿ Container compose-demo-web-1 Started 0.5s
root@docker:~/compose-demo# ../docker-compose ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
compo... nginx:alpine "/docker-entrypoint.…" web 52 seconds ago Up 51 seconds 0.0.0.0:8000->80/tcp, :::8000->80/tcp
Nun Test mit Browser: http://docker.lxd:8000 –> klappt!
Links
Änderungen
2022-12-26: Erste Version