Introduction to Docker
Tim Sangster
Software Engineer @ DataCamp
Image hello-world vytiskne text a poté se zastaví.
docker run hello-world
Hello from Docker!
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon created a new container from the hello-world image which runs the
executable that produces the output you are currently reading.
3. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
Image s Pythonem může při spuštění spustit Python.
docker run python3-sandbox
Python 3.10.6 (main, Nov 2 2022, 18:53:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
...
....
>>> exit()
repl@host:/#
CMD <shell-command>
Instrukce CMD:
Spuštění aplikace pro zpracování workflow nebo přijímání připojení.
CMD python3 my_pipeline.py
CMD postgres
Spuštění skriptu, který dále spustí více aplikací
CMD start.sh
CMD python3 start_pipeline.py
$$
$$
Obecnější image vyžaduje obecnější spouštěcí příkaz.
Spuštění image
docker run <image>
Spuštění image s vlastním příkazem
docker run <image> <shell-command>
Interaktivní spuštění image s vlastním příkazem
docker run -it <image> <shell-command>
docker run -it ubuntu bash
| Použití | Instrukce Dockerfile |
|---|---|
| Přidá příkaz shellu spouštěný při startu kontejneru z image. | CMD <shell-command> |
| Použití | Příkaz shellu |
|---|---|
| Přepsat CMD nastavený v image | docker run <image> <shell-command> |
| Přepsat CMD v image a spustit interaktivně | docker run -it <image> <shell-command> |
Introduction to Docker