Как настроить docker на linux

Linux post-installation steps for Docker Engine

These optional post-installation procedures shows you how to configure your Linux host machine to work better with Docker.

Manage Docker as a non-root user

The Docker daemon binds to a Unix socket, not a TCP port. By default it’s the root user that owns the Unix socket, and other users can only access it using sudo . The Docker daemon always runs as the root user.

If you don’t want to preface the docker command with sudo , create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group. On some Linux distributions, the system automatically creates this group when installing Docker Engine using a package manager. In that case, there is no need for you to manually create the group.

Warning

The docker group grants root-level privileges to the user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.

To create the docker group and add your user:

$ sudo usermod -aG docker $USER 

If you’re running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.

This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits. If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error:

WARNING: Error loading config file: /home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied 

This error indicates that the permission settings for the ~/.docker/ directory are incorrect, due to having used the sudo command earlier. To fix this problem, either remove the ~/.docker/ directory (it’s recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands:

$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R $ sudo chmod g+rwx "$HOME/.docker" -R 

Configure Docker to start on boot with systemd

Many modern Linux distributions use systemd to manage which services start when the system boots. On Debian and Ubuntu, the Docker service starts on boot by default. To automatically start Docker and containerd on boot for other Linux distributions using systemd, run the following commands:

$ sudo systemctl enable docker.service $ sudo systemctl enable containerd.service 

To stop this behavior, use disable instead.

$ sudo systemctl disable docker.service $ sudo systemctl disable containerd.service 

If you need to add an HTTP proxy, set a different directory or partition for the Docker runtime files, or make other customizations, see customize your systemd Docker daemon options.

Читайте также:  How to reset root password linux

Configure default logging driver

Docker provides logging drivers for collecting and viewing log data from all containers running on a host. The default logging driver, json-file , writes log data to JSON-formatted files on the host filesystem. Over time, these log files expand in size, leading to potential exhaustion of disk resources.

To avoid issues with overusing disk for log data, consider one of the following options:

  • Configure the json-file logging driver to turn on log rotation.
  • Use an alternative logging driver such as the “local” logging driver that performs log rotation by default.
  • Use a logging driver that sends logs to a remote logging aggregator.

Next steps

  • Read the Get started training modules to learn how to build an image and run it as a containerized application.
  • Review the topics in Develop with Docker to learn how to build new applications using Docker.

Источник

Установка Docker на Linux

Обновлено

Обновлено: 29.06.2023 Опубликовано: 25.07.2020

Используемые термины: Docker, Linux. Мы рассмотрим процесс установки Docker на популярные системы семейства Linux.

Ubuntu

Astra Linux

Rocky Linux / CentOS 8

CentOS 7

Fedora

РЕД ОС

Рекомендуемая настройка

<
«data-root»: «/opt/docker»,
«storage-driver»: «overlay2»,
«log-driver»: «json-file»,
«log-opts»: <
«max-size»: «10m»,
«max-file»: «3»
>
>

  • data-root — корневая директория, относительно которой будут создаваться служебные файлы и дисковые тома.
  • storage-driver — драйвер хранилища. На данный момент рекомендуется использовать overlay2.
  • log-driver — драйвер перехвата и хранения логов. Мы выставляем json-file, который для ведения журнала использует файловое хранилище.
  • log-opts — опции журнала. В данном примере мы ограничиваем объем 30 мб — 3 файла по 10 мб.

Для применения настроек перезапустим docker:

Проверка после установки и настройки

Чтобы убедиться, что docker в рабочем состоянии, выполняем команду:

Читайте также:  Linux терминал переименовать папку

Сначала система обнаружит, что нужного образа нет и загрузит его:

Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
b8dfde127a29: Already exists
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
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.

Docker работает корректно.

Установка Compose

Команда docker-compose позволяет развернуть многоконтейнерные Docker-приложения.

Для ее установка сначала убедимся в наличие пакета curl.

а) На системы DEB:

б) На системы RPM:

После переходим на страницу github.com/docker/compose/releases/latest и смотрим последнюю версию docker-compose.

curl -L «https://github.com/docker/compose/releases/download/v$COMVER/docker-compose-$(uname -s)-$(uname -m)» -o /usr/bin/docker-compose

* где 2.19.0 — последняя версия compose на момент обновления инструкции.

Даем права файлу на исполнение:

chmod +x /usr/bin/docker-compose

Запускаем docker-compose с выводом его версии:

Возможные проблемы

1. undefined symbol: seccomp_api_set

Сервис докера не запускается, а в логе можно увидеть следующий текст ошибки:

/usr/bin/containerd: symbol lookup error: /usr/bin/containerd: undefined symbol: seccomp_api_set

Причина: ошибка возникает, если установить свежую версию containerd на систему с необновленной библиотекой libseccomp.

Решение: обновляем libseccomp.

apt —only-upgrade install libseccomp2

2. error initializing network controller list bridge addresses failed no available network

Сервис докера не запускается, а в логе можно увидеть следующий текст ошибки:

error initializing network controller list bridge addresses failed no available network

Причина: система не может создать docker-интерфейс.

Решение: создаем docker-интерфейс вручную. Устанавливаем утилиту для работы с bridge-интерфейсами.

Назначаем IP-адреса на созданный интерфейс:

ip addr add 192.168.84.1/24 dev docker0

* в нашем примере для docker мы задали адрес 192.168.84.1.

Включаем созданный интерфейс:

ip link set dev docker0 up

Читайте также

Другие полезные инструкции:

Источник

Install Docker Engine

Docker Desktop for Linux

Docker Desktop helps you build, share, and run containers on Mac and Windows as you do on Linux. Docker Desktop for Linux is now GA. For more information, see Docker Desktop for Linux.

Supported platforms

Docker Engine is available on a variety of Linux distros, macOS, and Windows 10 through Docker Desktop, and as a static binary installation. Find your preferred operating system below.

Desktop

Server

Docker provides .deb and .rpm packages from the following Linux distros and architectures:

Platform x86_64 / amd64 arm64 / aarch64 arm (32-bit) s390x
CentOS
Debian
Fedora
Raspbian
RHEL
SLES
Ubuntu
Binaries

Other Linux distros

Note

While the instructions below may work, Docker doesn’t test or verify installation on distro derivatives.

  • Users of Debian derivatives such as “BunsenLabs Linux”, “Kali Linux” or “LMDE” (Debian-based Mint) should follow the installation instructions for Debian, substituting the version of their distro for the corresponding Debian release. Refer to the documentation of your distro to find which Debian release corresponds with your derivative version.
  • Likewise, users of Ubuntu derivatives such as “Kubuntu”, “Lubuntu” or “Xubuntu” should follow the installation instructions for Ubuntu, substituting the version of their distro for the corresponding Ubuntu release. Refer to the documentation of your distro to find which Ubuntu release corresponds with your derivative version.
  • Some Linux distros provide a package of Docker Engine through their package repositories. These packages are built and maintained by the Linux distro’s package maintainers and may have differences in configuration or built from modified source code. Docker isn’t involved in releasing these packages and you should report any bugs or issues involving these packages to your Linux distro’s issue tracker.
Читайте также:  Linux find mtime hours

Docker provides binaries for manual installation of Docker Engine. These binaries are statically linked and you can use them on any Linux distro.

Release channels

Docker Engine has two types of update channels, stable and test:

  • The Stable channel gives you the latest versions released for general availability.
  • The Test channel gives you pre-release versions that are ready for testing before general availability.

Use the test channel with caution. Pre-release versions include experimental and early-access features that are subject to breaking changes.

Support

Docker Engine is an open source project, supported by the Moby project maintainers and community members. Docker doesn’t provide support for Docker Engine. Docker provides support for Docker products, including Docker Desktop, which uses Docker Engine as one of its components.

For information about the open source project, refer to the Moby project website.

Upgrade path

Patch releases are always backward compatible with its major and minor version.

Licensing

Docker Engine is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Reporting security issues

If you discover a security issue, we request that you bring it to our attention immediately.

DO NOT file a public issue. Instead, submit your report privately to security@docker.com.

Security reports are greatly appreciated, and Docker will publicly thank you for it.

Get started

After setting up Docker, you can learn the basics with Getting started with Docker.

Источник

Оцените статью
Adblock
detector