Docker Handling: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Thomas (Diskussion | Beiträge) |
Thomas (Diskussion | Beiträge) |
||
| (30 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
=Dockerfile= | =Dockerfile= | ||
| − | == | + | ==Create Directory== |
| − | *mkdir ~/docker/im-bind9 | + | *mkdir -p ~/docker/im-bind9 |
| + | |||
==Dockerfile== | ==Dockerfile== | ||
~/docker/im-bind9# cat Dockerfile | ~/docker/im-bind9# cat Dockerfile | ||
| Zeile 28: | Zeile 29: | ||
REPOSITORY TAG IMAGE ID CREATED SIZE | REPOSITORY TAG IMAGE ID CREATED SIZE | ||
im-bind9-01 latest 2b3cce7dde64 About an hour ago 243 MB | im-bind9-01 latest 2b3cce7dde64 About an hour ago 243 MB | ||
| + | |||
=Container= | =Container= | ||
==Running== | ==Running== | ||
*docker run -d -p 53:53 -p 53:53/udp --name co-bind9-01 im-bind9-01 | *docker run -d -p 53:53 -p 53:53/udp --name co-bind9-01 im-bind9-01 | ||
==Inspect the Volumes== | ==Inspect the Volumes== | ||
| + | *sudo apt install jq | ||
*docker inspect -f "{{json .Mounts}}" co-bind9-01 | jq . | *docker inspect -f "{{json .Mounts}}" co-bind9-01 | jq . | ||
<pre> | <pre> | ||
| Zeile 57: | Zeile 60: | ||
] | ] | ||
</pre> | </pre> | ||
| + | |||
| + | =Mounts per Hand anlegen= | ||
| + | *docker run -d -p 81:80 '''-v /docker/xinux-wiki/html:/var/www/html''' --name xinux-wiki xinux-wiki-14.04-11 | ||
| + | *Der vordere Teil des Ausdrucks (vor dem ":") gibt dabei das Quellverzeichnis auf dem Host an, der hintere Teil (hinter dem ":") gibt das Zielverzeichnis auf dem Docker-Container an | ||
| + | |||
| + | ==Config the service== | ||
| + | ;/etc/bind | ||
| + | *cd /var/lib/docker/volumes/b0f0d3e275d537526c86f1a062f3955d6aa20392009df54af51598bee0032d5f/_data | ||
| + | ===Create a Zone=== | ||
| + | cat named.conf.local | ||
| + | <pre> | ||
| + | zone "vulkan.int" { | ||
| + | type master; | ||
| + | file "vulkan.int"; | ||
| + | notify no; | ||
| + | }; | ||
| + | </pre> | ||
| + | ===Create a Zonefile=== | ||
| + | ;/var/cache/bind | ||
| + | *cd /var/lib/docker/volumes/df518bd78593b927bf110a7fd12cb6734d0425366d281e2eb57cfbbf96b5901f/_data | ||
| + | *cat vulkan.int | ||
| + | <pre> | ||
| + | $TTL 300 ; 5 minutes | ||
| + | @ IN SOA ns.vulkan.int. technik.xunix.de. ( | ||
| + | 2011090204 ; serial | ||
| + | 14400 ; refresh (4 hours) | ||
| + | 3600 ; retry (1 hour) | ||
| + | 3600000 ; expire (5 weeks 6 days 16 hours) | ||
| + | 86400 ; minimum (1 day) | ||
| + | ) | ||
| + | NS ns.vulkan.int. | ||
| + | ns.vulkan.int. A 172.17.0.2 | ||
| + | www.vulkan.int. CNAME waka.xinux.lan. | ||
| + | </pre> | ||
| + | ==Check Container== | ||
| + | *docker ps -l | ||
| + | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | ||
| + | 5fb1f648756f im-bind9-01 "/usr/sbin/named -..." 18 minutes ago Up 18 minutes 0.0.0.0:53->53/tcp, 0.0.0.0:53->53/udp co-bind9-01 | ||
| + | ==Restart Container== | ||
| + | *docker restart co-bind9-01 | ||
| + | ==Check Service== | ||
| + | *host -t cname www.vulkan.int 127.0.0.1 | ||
| + | Using domain server: | ||
| + | Name: 127.0.0.1 | ||
| + | Address: 127.0.0.1#53 | ||
| + | Aliases: | ||
| + | |||
| + | www.vulkan.int is an alias for waka.xinux.lan. | ||
| + | =Integration to Systemd= | ||
| + | *[[Docker Container Systemd]] | ||
| + | |||
| + | =Misc= | ||
| + | ==Enter to a running Container== | ||
| + | *docker exec -it co-bind9-01 /bin/bash | ||
| + | ==Leave the Container== | ||
| + | *Type CTRL + a + d | ||
| + | ==Show Running Container== | ||
| + | *docker ps | ||
| + | <pre> | ||
| + | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | ||
| + | 5fb1f648756f im-bind9-01 "/usr/sbin/named -..." 15 hours ago Up 14 hours 0.0.0.0:53->53/tcp, 0.0.0.0:53->53/udp, 953/udp co-bind9-01 | ||
| + | 2f7b36514443 im-bind-06 "/usr/sbin/named -..." 15 hours ago Up 15 hours 53/udp, 53/tcp, 953/udp co-bind-06 | ||
| + | 1d7810a7b89e nickstenning/mediawiki "/usr/bin/mediawik..." 17 hours ago Up 15 hours 0.0.0.0:80->80/tcp xinux-wiki | ||
| + | 51af44ac62b7 mysql "docker-entrypoint..." 18 hours ago Up 15 hours 0.0.0.0:3306->3306/tcp xinux-mysql | ||
| + | </pre> | ||
| + | ==Stop Container== | ||
| + | *docker stop co-bind9-01 | ||
| + | ==Remove Container== | ||
| + | *docker rm co-bind9-01 | ||
| + | =Repository= | ||
| + | ==Login== | ||
| + | *docker login docker.yourdomain.de | ||
| + | ==Tagen== | ||
| + | *docker tag im-bind9-02 docker.yourdomain.de/im-bind9-02 | ||
| + | ==Push== | ||
| + | *docker push docker.yourdomain.de/im-bind9-02 | ||
| + | |||
| + | ==Pull a Image== | ||
| + | *docker pull docker.yourdomain.de/im-bind9-02 | ||
| + | |||
| + | =Links= | ||
| + | *http://container-solutions.com/understanding-volumes-docker/ | ||
| + | *https://www.alexandernaumov.de/blog/docker-grundlagen | ||
Aktuelle Version vom 26. November 2017, 15:14 Uhr
Dockerfile
Create Directory
- mkdir -p ~/docker/im-bind9
Dockerfile
~/docker/im-bind9# cat Dockerfile
#Grundimage hier ubuntu 16:04 FROM ubuntu:16.04 #maintainer sind wir MAINTAINER technik@xinux.de #Dies wird beim build und nur beim build ausgeführt RUN apt-get update && apt-get install -y bind9 #Frei zugebender Ports EXPOSE 53 EXPOSE 53/UDP #Verzeichnis welches wir zum mount vorbereiten VOLUME ["/var/cache/bind/"] VOLUME ["/etc/bind/"] #Abschliessendes Kommando beim container erstellen, muss im vordergrund laufen CMD ["/usr/sbin/named","-f", "-u", "bind" ]
Build
- cd ~/docker/im-bind9
- docker build -t im-bind9-01 .
Listing
- docker images
REPOSITORY TAG IMAGE ID CREATED SIZE im-bind9-01 latest 2b3cce7dde64 About an hour ago 243 MB
Container
Running
- docker run -d -p 53:53 -p 53:53/udp --name co-bind9-01 im-bind9-01
Inspect the Volumes
- sudo apt install jq
- docker inspect -f "Vorlage:Json .Mounts" co-bind9-01 | jq .
[
{
"Type": "volume",
"Name": "b0f0d3e275d537526c86f1a062f3955d6aa20392009df54af51598bee0032d5f",
"Source": "/var/lib/docker/volumes/b0f0d3e275d537526c86f1a062f3955d6aa20392009df54af51598bee0032d5f/_data",
"Destination": "/etc/bind",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
},
{
"Type": "volume",
"Name": "df518bd78593b927bf110a7fd12cb6734d0425366d281e2eb57cfbbf96b5901f",
"Source": "/var/lib/docker/volumes/df518bd78593b927bf110a7fd12cb6734d0425366d281e2eb57cfbbf96b5901f/_data",
"Destination": "/var/cache/bind",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
]
Mounts per Hand anlegen
- docker run -d -p 81:80 -v /docker/xinux-wiki/html:/var/www/html --name xinux-wiki xinux-wiki-14.04-11
- Der vordere Teil des Ausdrucks (vor dem ":") gibt dabei das Quellverzeichnis auf dem Host an, der hintere Teil (hinter dem ":") gibt das Zielverzeichnis auf dem Docker-Container an
Config the service
- /etc/bind
- cd /var/lib/docker/volumes/b0f0d3e275d537526c86f1a062f3955d6aa20392009df54af51598bee0032d5f/_data
Create a Zone
cat named.conf.local
zone "vulkan.int" {
type master;
file "vulkan.int";
notify no;
};
Create a Zonefile
- /var/cache/bind
- cd /var/lib/docker/volumes/df518bd78593b927bf110a7fd12cb6734d0425366d281e2eb57cfbbf96b5901f/_data
- cat vulkan.int
$TTL 300 ; 5 minutes
@ IN SOA ns.vulkan.int. technik.xunix.de. (
2011090204 ; serial
14400 ; refresh (4 hours)
3600 ; retry (1 hour)
3600000 ; expire (5 weeks 6 days 16 hours)
86400 ; minimum (1 day)
)
NS ns.vulkan.int.
ns.vulkan.int. A 172.17.0.2
www.vulkan.int. CNAME waka.xinux.lan.
Check Container
- docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5fb1f648756f im-bind9-01 "/usr/sbin/named -..." 18 minutes ago Up 18 minutes 0.0.0.0:53->53/tcp, 0.0.0.0:53->53/udp co-bind9-01
Restart Container
- docker restart co-bind9-01
Check Service
- host -t cname www.vulkan.int 127.0.0.1
Using domain server: Name: 127.0.0.1 Address: 127.0.0.1#53 Aliases: www.vulkan.int is an alias for waka.xinux.lan.
Integration to Systemd
Misc
Enter to a running Container
- docker exec -it co-bind9-01 /bin/bash
Leave the Container
- Type CTRL + a + d
Show Running Container
- docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5fb1f648756f im-bind9-01 "/usr/sbin/named -..." 15 hours ago Up 14 hours 0.0.0.0:53->53/tcp, 0.0.0.0:53->53/udp, 953/udp co-bind9-01 2f7b36514443 im-bind-06 "/usr/sbin/named -..." 15 hours ago Up 15 hours 53/udp, 53/tcp, 953/udp co-bind-06 1d7810a7b89e nickstenning/mediawiki "/usr/bin/mediawik..." 17 hours ago Up 15 hours 0.0.0.0:80->80/tcp xinux-wiki 51af44ac62b7 mysql "docker-entrypoint..." 18 hours ago Up 15 hours 0.0.0.0:3306->3306/tcp xinux-mysql
Stop Container
- docker stop co-bind9-01
Remove Container
- docker rm co-bind9-01
Repository
Login
- docker login docker.yourdomain.de
Tagen
- docker tag im-bind9-02 docker.yourdomain.de/im-bind9-02
Push
- docker push docker.yourdomain.de/im-bind9-02
Pull a Image
- docker pull docker.yourdomain.de/im-bind9-02