-
Notifications
You must be signed in to change notification settings - Fork 941
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(*:skip) Update Docker documentation (#3722)
Signed-off-by: Robert Steiner <[email protected]>
- Loading branch information
1 parent
53176af
commit abde02e
Showing
13 changed files
with
743 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
Enable TLS for Secure Connections | ||
================================= | ||
|
||
When operating in a production environment, it is strongly recommended to enable Transport Layer | ||
Security (TLS) for each Flower Component to ensure secure communication. | ||
|
||
To enable TLS, you will need a PEM-encoded root certificate, a PEM-encoded private key and a | ||
PEM-encoded certificate chain. | ||
|
||
.. note:: | ||
|
||
For testing purposes, you can generate your own self-signed certificates. The | ||
`Enable SSL connections <https://flower.ai/docs/framework/how-to-enable-ssl-connections.html#certificates>`__ | ||
page contains a section that will guide you through the process. | ||
|
||
|
||
Because Flower containers, by default, run with a non-root user ``app``, the mounted files and | ||
directories must have the proper permissions for the user ID ``49999``. | ||
|
||
For example, to change the user ID of all files in the ``certificates/`` directory, you can run | ||
``sudo chown -R 49999:49999 certificates/*``. | ||
|
||
If you later want to delete the directory, you can change the user ID back to the current user | ||
ID by running ``sudo chown -R $USER:$(id -gn) state``. | ||
|
||
SuperLink | ||
--------- | ||
|
||
Assuming all files we need are in the local ``certificates`` directory, we can use the flag | ||
``--volume`` to mount the local directory into the ``/app/certificates/`` directory of the container: | ||
|
||
.. code-block:: bash | ||
:substitutions: | ||
$ docker run --rm \ | ||
--volume ./certificates/:/app/certificates/:ro \ | ||
flwr/superlink:|stable_flwr_version| \ | ||
--ssl-ca-certfile certificates/ca.crt \ | ||
--ssl-certfile certificates/server.pem \ | ||
--ssl-keyfile certificates/server.key | ||
.. dropdown:: Understanding the command | ||
|
||
* ``docker run``: This tells Docker to run a container from an image. | ||
* ``--rm``: Remove the container once it is stopped or the command exits. | ||
* | ``--volume ./certificates/:/app/certificates/:ro``: Mount the ``certificates`` directory in | ||
| the current working directory of the host machine as a read-only volume at the | ||
| ``/app/certificates`` directory inside the container. | ||
| | ||
| This allows the container to access the TLS certificates that are stored in the certificates | ||
| directory. | ||
* | :substitution-code:`flwr/superlink:|stable_flwr_version|`: The name of the image to be run and the specific | ||
| tag of the image. The tag :substitution-code:`|stable_flwr_version|` represents a specific version of the image. | ||
* | ``--ssl-ca-certfile certificates/ca.crt``: Specify the location of the CA certificate file | ||
| inside the container. | ||
| | ||
| The ``certificates/ca.crt`` file is a certificate that is used to verify the identity of the | ||
| SuperLink. | ||
* | ``--ssl-certfile certificates/server.pem``: Specify the location of the SuperLink's | ||
| TLS certificate file inside the container. | ||
| | ||
| The ``certificates/server.pem`` file is used to identify the SuperLink and to encrypt the | ||
| data that is transmitted over the network. | ||
* | ``--ssl-keyfile certificates/server.key``: Specify the location of the SuperLink's | ||
| TLS private key file inside the container. | ||
| | ||
| The ``certificates/server.key`` file is used to decrypt the data that is transmitted over | ||
| the network. | ||
SuperNode | ||
--------- | ||
|
||
Assuming that the ``ca.crt`` certificate already exists locally, we can use the flag ``--volume`` to mount the local | ||
certificate into the container's ``/app/`` directory. | ||
|
||
.. note:: | ||
|
||
If you're generating self-signed certificates and the ``ca.crt`` certificate doesn't exist | ||
on the SuperNode, you can copy it over after the generation step. | ||
|
||
.. code-block:: bash | ||
:substitutions: | ||
$ docker run --rm \ | ||
--volume ./ca.crt:/app/ca.crt/:ro \ | ||
flwr/supernode:|stable_flwr_version| \ | ||
--root-certificates ca.crt | ||
.. dropdown:: Understanding the command | ||
|
||
* ``docker run``: This tells Docker to run a container from an image. | ||
* ``--rm``: Remove the container once it is stopped or the command exits. | ||
* | ``--volume ./ca.crt:/app/ca.crt/:ro``: Mount the ``ca.crt`` file from the | ||
| current working directory of the host machine as a read-only volume at the ``/app/ca.crt`` | ||
| directory inside the container. | ||
* | :substitution-code:`flwr/supernode:|stable_flwr_version|`: The name of the image to be run and the specific | ||
| tag of the image. The tag :substitution-code:`|stable_flwr_version|` represents a specific version of the image. | ||
* | ``--root-certificates ca.crt``: This specifies the location of the CA certificate file | ||
| inside the container. | ||
| | ||
| The ``ca.crt`` file is used to verify the identity of the SuperLink. | ||
|
||
SuperExec | ||
--------- | ||
|
||
Assuming all files we need are in the local ``certificates`` directory where the SuperExec will be executed from, we can use the flag | ||
``--volume`` to mount the local directory into the ``/app/certificates/`` directory of the container: | ||
|
||
.. code-block:: bash | ||
:substitutions: | ||
$ docker run --rm \ | ||
--volume ./certificates/:/app/certificates/:ro \ | ||
flwr/superexec:|stable_flwr_version| \ | ||
--ssl-ca-certfile certificates/ca.crt \ | ||
--ssl-certfile certificates/server.pem \ | ||
--ssl-keyfile certificates/server.key \ | ||
--executor-config \ | ||
root-certificates=\"certificates/superlink_ca.crt\" | ||
.. dropdown:: Understanding the command | ||
|
||
* ``docker run``: This tells Docker to run a container from an image. | ||
* ``--rm``: Remove the container once it is stopped or the command exits. | ||
* | ``--volume ./certificates/:/app/certificates/:ro``: Mount the ``certificates`` directory in | ||
| the current working directory of the host machine as a read-only volume at the | ||
| ``/app/certificates`` directory inside the container. | ||
| | ||
| This allows the container to access the TLS certificates that are stored in the certificates | ||
| directory. | ||
* | :substitution-code:`flwr/superexec:|stable_flwr_version|`: The name of the image to be run and the specific | ||
| tag of the image. The tag :substitution-code:`|stable_flwr_version|` represents a specific version of the image. | ||
* | ``--ssl-ca-certfile certificates/ca.crt``: Specify the location of the CA certificate file | ||
| inside the container. | ||
| | ||
| The ``certificates/ca.crt`` file is a certificate that is used to verify the identity of the | ||
| SuperExec. | ||
* | ``--ssl-certfile certificates/server.pem``: Specify the location of the SuperExec's | ||
| TLS certificate file inside the container. | ||
| | ||
| The ``certificates/server.pem`` file is used to identify the SuperExec and to encrypt the | ||
| data that is transmitted over the network. | ||
* | ``--ssl-keyfile certificates/server.key``: Specify the location of the SuperExec's | ||
| TLS private key file inside the container. | ||
| | ||
| The ``certificates/server.key`` file is used to decrypt the data that is transmitted over | ||
| the network. | ||
* | ``--executor-config root-certificates=\"certificates/superlink_ca.crt\"``: Specify the | ||
| location of the CA certificate file inside the container that the SuperExec executor | ||
| should use to verify the SuperLink's identity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Run Flower using Docker | ||
======================= | ||
|
||
Start your Flower journey with our pre-made Docker images on Docker Hub, supporting ``amd64`` | ||
and ``arm64v8`` architectures. | ||
|
||
Our Quickstart guide walks you through containerizing a Flower project and running it end to | ||
end using Docker. | ||
|
||
Getting Started | ||
--------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
tutorial-quickstart-docker | ||
|
||
|
||
Running in Production | ||
--------------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
enable-tls | ||
persist-superlink-state | ||
|
||
Advanced Options | ||
---------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
set-environment-variables | ||
run-as-root-user | ||
pin-version | ||
use-a-different-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Persist the State of the SuperLink | ||
================================== | ||
|
||
By default, the Flower SuperLink keeps its state in-memory. When using the Docker flag ``--rm``, the | ||
state is not persisted between container starts. | ||
|
||
If you want to persist the state of the SuperLink on your host system, all you need to do is specify | ||
a directory where you want to save the file on your host system and a name for the database file. | ||
|
||
By default, the SuperLink container runs with a non-root user called ``app`` with the user ID | ||
``49999``. It is recommended to create a new directory and change the user ID of the directory to | ||
``49999`` to ensure the mounted directory has the proper permissions. | ||
|
||
If you later want to delete the directory, you can change the user ID back to the current user | ||
ID by running ``sudo chown -R $USER:$(id -gn) state``. | ||
|
||
Example | ||
------- | ||
|
||
In the example below, we create a new directory called ``state``, change the user ID and tell | ||
Docker via the flag ``--volume`` to mount the local ``state`` directory into the ``/app/state`` | ||
directory of the container. Lastly, we use the flag ``--database`` to specify the name of the | ||
database file. | ||
|
||
.. code-block:: bash | ||
:substitutions: | ||
$ mkdir state | ||
$ sudo chown -R 49999:49999 state | ||
$ docker run --rm \ | ||
--volume ./state/:/app/state flwr/superlink:|stable_flwr_version| \ | ||
--database state.db \ | ||
... | ||
As soon as the SuperLink starts, the file ``state.db`` is created in the ``state`` directory on | ||
your host system. If the file already exists, the SuperLink tries to restore the state from the | ||
file. To start the SuperLink with an empty database, ensure that there is no database | ||
called ``state.db`` in the ``state`` directory (``rm state.db``) before you execute the | ||
``docker run`` command above. |
Oops, something went wrong.