> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuración de las capacidades CAP_IPC_LOCK y CAP_SYS_NICE en Docker

> Aprende a resolver las advertencias de Docker sobre las capacidades `CAP_IPC_LOCK` y `CAP_SYS_NICE` al ejecutar ClickHouse en un contenedor.

<div id="question">
  ## Pregunta
</div>

Al ejecutar ClickHouse en Docker, Docker informa que faltan las capacidades `CAP_IPC_LOCK` y `CAP_SYS_NICE` en el sistema. ¿Cómo puedo solucionarlo?

Así se ven los mensajes de registro cuando falta la capacidad `CAP_SYS_NICE` o `CAP_SYS_NICE`:

```bash theme={null}
docker run -d --name clickhouse-server \
    --ulimit nofile=262144:262144 \
    --network clickhouse-net \
    -p 8123:8123 -p 9000:9000 -p 9009:9009 -p 9363:9363 \
    clickhouse/clickhouse-server:23.2
```

```response theme={null}
2023.04.19 08:04:10.022720 [ 1 ] {} <Information> Application: It looks like the process has no CAP_IPC_LOCK capability, binary mlock will be disabled. It could happen due to incorrect ClickHouse package installation. You could resolve the problem manually with 'sudo setcap cap_ipc_lock=+ep /usr/bin/clickhouse'. Note that it will not work on 'nosuid' mounted filesystems.

2023.04.19 08:04:10.065860 [ 1 ] {} <Information> Application: It looks like the process has no CAP_SYS_NICE capability, the setting 'os_thread_priority' will have no effect. It could happen due to incorrect ClickHouse package installation. You could resolve the problem manually with 'sudo setcap cap_sys_nice=+ep /usr/bin/clickhouse'. Note that it will not work on 'nosuid' mounted filesystems.
```

<div id="answer">
  ## Respuesta
</div>

1. Agregue dos argumentos `--cap-add` para otorgar al contenedor las capacidades `IPC_LOCK` y `SYS_NICE`:

```bash theme={null}
docker run -d --name clickhouse-server \
   --cap-add=SYS_NICE \
   --cap-add=IPC_LOCK \
   --ulimit nofile=262144:262144 \
   --network clickhouse-net \
   -p 8123:8123 -p 9000:9000 -p 9009:9009 -p 9363:9363 \
   clickhouse/clickhouse-server:23.2
```

2. Compruebe que las capacidades estén visibles en el contenedor mediante el siguiente comando:

```bash theme={null}
apt-get update > /dev/null && apt-get install -y libcap2-bin > /dev/null && capsh --print
```

La respuesta es similar a:

```response theme={null}
debconf: delaying package configuration, since apt-utils is not installed
WARNING: libcap needs an update (cap=40 should have a name).
Current: = cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_ipc_lock,cap_sys_chroot,cap_sys_nice,cap_mknod,cap_audit_write,cap_setfcap+ep
Bounding set =cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_ipc_lock,cap_sys_chroot,cap_sys_nice,cap_mknod,cap_audit_write,cap_setfcap
Ambient set =
Securebits: 00/0x0/1'b0
 secure-noroot: no (unlocked)
 secure-no-suid-fixup: no (unlocked)
 secure-keep-caps: no (unlocked)
 secure-no-ambient-raise: no (unlocked)
uid=0(root) euid=0(root)
gid=0(root)
groups=0(root)
Guessed mode: UNCERTAIN (0)
```

3. Configura manualmente ambas capacidades para ClickHouse

```bash theme={null}
setcap "cap_ipc_lock=+ep cap_sys_nice=+ep" /usr/bin/clickhouse
```

4. Compruebe que se hayan aplicado las capacidades.

```bash theme={null}
getcap -v /usr/bin/clickhouse
```

Deberías ver lo siguiente:

```response theme={null}
/usr/bin/clickhouse = cap_ipc_lock,cap_sys_nice+ep
```

5. Reinicie el servidor de ClickHouse y los mensajes de log ya no deberían mostrarse.

<br />

Consulte este [artículo sobre las capacidades de Linux](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities) para obtener más detalles.
