Gut, ich bin nicht der einzige, der ständig damit Probleme hat. @tkaiser auch 😉
1036201d-a4b2-47be-a618-36003c07e0ce-grafik.png
Morgens beim Kaffee mal schnell was ausprobieren
Das Docker Image vom Kamil auf eine SD-Karte gebügelt. Ab in den ROCKPro64 und starten.
rock64@rockpro64:~$ docker
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default
"/home/rock64/.docker")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level
("debug"|"info"|"warn"|"error"|"fatal")
(default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default
"/home/rock64/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default
"/home/rock64/.docker/cert.pem")
--tlskey string Path to TLS key file (default
"/home/rock64/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
config Manage Docker configs
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
deploy Deploy a new stack or update an existing stack
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
Ok, Docker ist installiert und läuft.
rock64@rockpro64:~$ sudo docker run -t ubuntu:18.04 /bin/echo "Hello World"
[sudo] password for rock64:
Unable to find image 'ubuntu:18.04' locally
18.04: Pulling from library/ubuntu
7dc40899884d: Pull complete
3c3b1bd6c6b3: Pull complete
f2b826692f9c: Pull complete
836583884d3e: Pull complete
27ede898dd26: Pull complete
Digest: sha256:de774a3145f7ca4f0bd144c7d4ffb2931e06634f11529653b23eba85aef8e378
Status: Downloaded newer image for ubuntu:18.04
Hello World
Nicht wirklich spannend
rock64@rockpro64:~$ sudo docker run -d --name demo_nginx -p 80:80 nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
8d586fc79193: Pull complete
542be7cb76c8: Pull complete
4c1ed6d3c37c: Pull complete
Digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
Status: Downloaded newer image for nginx:latest
0b603cb5fa5b4ebf9113eb916b4dbc3d2cf48db8edf5b744d8b40eb6792b22dc
Jetzt haben wir einen Docker Container mit nginx am Laufen. Mit dem Befehl docker ps kann man sich die laufenden Container anzeigen lassen.
rock64@rockpro64:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b603cb5fa5b nginx "nginx -g 'daemon of…" 8 seconds ago Up 7 seconds 0.0.0.0:80->80/tcp demo_nginx
sudo docker exec -it 0b603cb5fa5b bash
und schwupps, sind wir auf der Konsole.
Mal eben nano nachinstallieren.
root@0b603cb5fa5b:/# apt-get update
Get:1 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Ign:2 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:3 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:4 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]
Get:6 http://security.debian.org/debian-security stretch/updates/main arm64 Packages [421 kB]
Get:7 http://cdn-fastly.deb.debian.org/debian stretch-updates/main arm64 Packages [5096 B]
Get:8 http://cdn-fastly.deb.debian.org/debian stretch/main arm64 Packages [6940 kB]
Fetched 7672 kB in 3s (1962 kB/s)
Reading package lists... Done
root@0b603cb5fa5b:/# apt-get install nano
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
spell
The following NEW packages will be installed:
nano
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 474 kB of archives.
After this operation, 2088 kB of additional disk space will be used.
Get:1 http://cdn-fastly.deb.debian.org/debian stretch/main arm64 nano arm64 2.7.4-1 [474 kB]
Fetched 474 kB in 0s (764 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package nano.
(Reading database ... 7135 files and directories currently installed.)
Preparing to unpack .../nano_2.7.4-1_arm64.deb ...
Unpacking nano (2.7.4-1) ...
Setting up nano (2.7.4-1) ...
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group editor) doesn't exist
update-alternatives: using /bin/nano to provide /usr/bin/pico (pico) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/pico.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group pico) doesn't exist
Was müssen wir noch testen? Ob nginx läuft. Dazu im Webbrowser folgendes eingeben
http://192.168.3.19/
Das ist jetzt die IP-Adresse, mit der mein ROCKPro64 läuft.
Soweit, sieht das ja brauchbar aus. Mal ein wenig mit rumspielen
rock64@rockpro64:~$ sudo docker stop 0b603cb5fa5b
0b603cb5fa5b
rock64@rockpro64:~$ sudo docker start 0b603cb5fa5b
0b603cb5fa5b
Und es gibt noch viel mehr da zu entdecken. Wird fortgesetzt......
root@rockpro64:/usr/local/sbin# docker info
Containers: 4
Running: 0
Paused: 0
Stopped: 4
Images: 4
Server Version: 18.09.3
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
....
Vorhandene Images auflisten.
root@rockpro64:/usr/local/sbin# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
my/nginx latest d6d53e05e4c8 45 hours ago 103MB
nginx latest c190496bcbad 3 days ago 103MB
debian latest 1c2fcfa9d61f 3 days ago 95.8MB
ubuntu 18.04 0926e73e5245 2 weeks ago 80.4MB
root@rockpro64:~/docker_test# docker run -p 4000:80 friendlyhello
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
192.168.3.213 - - [30/Mar/2019 17:23:38] "GET / HTTP/1.1" 200 -
192.168.3.213 - - [30/Mar/2019 17:23:38] "GET /favicon.ico HTTP/1.1" 404 -
root@rockpro64:~/docker_test# docker run -d -p 4000:80 friendlyhello
0b9d4c5878b50dca6d820b2597a1c5128c176d7d4f7563d4ecbc8203fd28f8b3
Wir verfeinern das Ganze mal. Den Anfang macht der nginx Docker Container
Als Basis dient das Docker-Image vom Kamil.
Hier die rc5 Version
root@rockpro64:~# uname -a
Linux rockpro64 4.4.167-1161-rockchip-ayufan-g6f1664023387 #1 SMP Fri Mar 22 23:03:38 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
docker pull nginx
docker run -d -p 80:80 nginx
root@rockpro64:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef0c26f78268 nginx "nginx -g 'daemon of…" 4 minutes ago Up 4 minutes 0.0.0.0:80->80/tcp heuristic_mirzakhani
docker exec -it ef0c26f78268 bash
Danach befindet man sich auf der Konsole, innerhalb des Containers. Dort kann man dann Änderungen vornehmen, nur blöd, das die nicht permanent sind. Dafür muss man noch was machen.
Den Container, den man sich holt, dient nur als Grundlage. Also die konsole betreten, die Änderungen eintragen. Beispiel:
apt update
apt upgrade
apt install nano
nano /usr/share/nginx/html/index.html
In der Datei ändern wir folgendes
<h1>Welcome to nginx! ***TEST***</h1>
Jetzt kann man die Konsole wieder verlassen.
exit
Wenn man nun den Container stoppen würde und erneut starten würde, wären alle Änderungen weg. Man bekommt immer den Stand, den man sich mittels pull gezogen hat. OK, das kann man aber auch permanent machen.
root@rockpro64:~# docker commit ef0c26f78268 nginx_test
Mit diesem Befehl erzeuge ich aus dem Container nginx den neuen Container nginx_test mit allen meinen Änderungen. Das sieht man hier
root@rockpro64:~# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx_test latest 05b57c23e8c5 32 seconds ago 124MB
nginx latest 2ba173e8977e 2 days ago 103MB
Nun stoppt man den ersten Container nginx und startet seinen neuen Container nginx_test, mit allen Änderungen.
Die findet man unter
nano /etc/nginx/conf.d/default.conf
Das ganze hat einen furchtbar schönen Vorteil. Mal angenommen, ich habe ein NodeBB-Forum in einem Container laufen. Will das Ding updaten und das crasht einfach mal so. Egal, Container stoppen, Container starten und alles läuft wieder.
Mit dem Commit sichere ich mir dann den Zustand nachdem ich weiß, das alles klappt