Додати офіційний ключ GPG репозиторію пакунків Docker:
# curl -fsSL https://apt.dockerproject.org/gpg | sudo apt-key add -
Перевірити контрольну сигнатуру ключа:
# apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D
pub 4096R/2C52609D 2015-07-14
Key fingerprint = 5811 8E89 F3A9 1289 7C07 0ADB F762 2157 2C52 609D
uid Docker Release Tool (releasedocker) <docker@docker.com>
# apt-add-repository "deb https://apt.dockerproject.org/repo/ \
ubuntu-$(lsb_release -cs) main"
Оновити інформацію про пакунки в репозиторіях
# apt update
Встановити пакунок docker-engine останньої версії:
# apt install docker-engine
Демон docker стартує автоматично:
# systemctl status docker
● docker.service - Docker Application Container EngineLoaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2017-05-14 20:58:56 EEST; 24s ago
...
Отримати інформацію про встановлений пакунок:
# docker version
Client:
Version: 17.05.0-ce
API version: 1.29
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:20:42 2017
OS/Arch: linux/amd64
Server:
Version: 17.05.0-ce
API version: 1.29 (minimum version 1.12)
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:20:42 2017
OS/Arch: linux/amd64
Experimental: false
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 17.05.0-ce
Завантажити docker-образ і запустити тестовий контейнер:
# docker version
Client:
Version: 17.05.0-ce
API version: 1.29
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:20:42 2017
OS/Arch: linux/amd64
Server:
Version: 17.05.0-ce
API version: 1.29 (minimum version 1.12)
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:20:42 2017
OS/Arch: linux/amd64
Experimental: false
# docker info
Containers: 0Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 17.05.0-ce
...
Завантажити docker-образ і запустити тестовий контейнер:
# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
В результаті виконання останньої команди були виконані наступні дії.
- Виконаний пошук docker-образу hello-world на локальному диску
- Оскільки на локальному диску docker-образу hello-world не знайдено, виконано звернення до репозиторію образів на Docker Hub
- Завантажено образ hello-world з Docker Hub
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 48b5124b2768 4 months ago 1.84kB
- З завантаженого образу створено контейнер з ідентифікатором db8d8d79e7b4 та іменем upbeat_kepler
# docker container ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
db8d8d79e7b4 hello-world "/hello" 6 minutes ago Exited (0) 6 minutes ago upbeat_kepler
# docker container rm db8d8d79e7b4
db8d8d79e7b4
Контейнер може видалятися автоматично після завершення виконання, якщо його запуск здійснюється з опцією --rm:
# docker container run --rm hello-world
Завантажений образ також може бути видалений:
# docker image rm 48b5124b2768
Untagged: hello-world:latest
Untagged: hello-world@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Deleted: sha256:48b5124b2768d2b917edcb640435044a97967015485e812545546cbed5cf0233
Deleted: sha256:98c944e98de8d35097100ff70a31083ec57704be0991a92c51700465e4544d08
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
db8d8d79e7b4 hello-world "/hello" 6 minutes ago Exited (0) 6 minutes ago upbeat_kepler
- Під час свого запуску контейнер виконує команду /hello
- Вивід команди відображається в термінальному вікні
- Контейнер завершує своє функціювання
# docker container rm db8d8d79e7b4
db8d8d79e7b4
Контейнер може видалятися автоматично після завершення виконання, якщо його запуск здійснюється з опцією --rm:
# docker container run --rm hello-world
Завантажений образ також може бути видалений:
# docker image rm 48b5124b2768
Untagged: hello-world:latest
Untagged: hello-world@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Deleted: sha256:48b5124b2768d2b917edcb640435044a97967015485e812545546cbed5cf0233
Deleted: sha256:98c944e98de8d35097100ff70a31083ec57704be0991a92c51700465e4544d08
Немає коментарів:
Дописати коментар