If you choose to not move the `influxd` binary into your `$PATH`, enter the path to the binary to start the server--for example:
If you choose to not move the `influxd` binary into your `$PATH`, enter the
path to the binary to start the server--for example:
<!--pytest.mark.skip-->
@ -342,9 +347,13 @@ You can use systemd to customize [InfluxDB configuration options](/influxdb/v2/r
{{<expand-wrapper>}}
{{% expand "<spanclass='req'>Recommended</span>– Set appropriate directory permissions" %}}
To prevent unwanted access to data, set the permissions on the influxdb `data-dir` to not be world readable.
If installing on a server, we recommend setting a umask of `0027` to properly permission all newly created files.
To set umask, use a UMask directive in a systemd unit file or run Influxdb as a specific user that has the umask properly set--for example, enter the following command in your terminal:
To prevent unwanted access to data, set the permissions on the influxdb
`data-dir` to not be world readable.
If installing on a server, we recommend setting a umask of `0027` to properly
permission all newly created files.
To set umask, use a UMask directive in a systemd unit file or run Influxdb as a
specific user that has the umask properly set--for example, enter the following
command in your terminal:
<!--pytest.mark.skip-->
@ -386,8 +395,8 @@ To install `gpg`, see the [GnuPG installation instructions](https://gnupg.org/do
{{% expand "<spanclass='req'>Recommended</span>– Set appropriate directory permissions" %}}
To prevent unwanted access to data, we recommend setting the permissions on the influxdb `data-dir` to not be world readable--for example: enter the following commands in your terminal:
To prevent unwanted access to data, we recommend setting the permissions on the
influxdb `data-dir` to not be world readable--for example: enter the following
The following guide uses [Docker CLI commands](https://docs.docker.com/reference/cli/docker/) to set Docker and InfluxDB options, but you can also use Dockerfiles and Docker Compose.
The following steps show to use the
[Docker CLI](https://docs.docker.com/reference/cli/docker/) to set up and
1. Follow instructions to install [Docker Desktop](https://www.docker.com/get-started/) for your system.
2. Start a Docker container from the [`influxdb` Docker Hub image](https://hub.docker.com/_/influxdb)--for example, in your terminal, enter the `docker run influxdb:2` command with command line flags for initial setup options and file system mounts.
_The following guide uses Docker mounted
[volumes](https://docs.docker.com/storage/volumes/) to persist InfluxDB
configuration and data.
Persisting your data to a file system outside the container ensures that your
data isn't deleted if you delete the container._
The following example uses the Docker `--mount` option to persist InfluxDB configuration and data to [volumes](https://docs.docker.com/storage/volumes/).
_Persisting your data to a file system outside the container ensures that your data isn't deleted if you delete the container._
1. Install [Docker Desktop](https://www.docker.com/get-started/) for your system.
<!--pytest.mark.skip-->
2. Start a Docker container from the
[`influxdb` Docker Hub image](https://hub.docker.com/_/influxdb)--for example,
in your terminal, enter the `docker run influxdb:2` command with command line
flags for initial setup options and file system mounts.
_If you don't specify InfluxDB initial setup options, you can
[set up manually](#set-up-influxdb) later using the UI or CLI in a running
@ -497,39 +527,70 @@ The following guide uses [Docker CLI commands](https://docs.docker.com/reference
--env DOCKER_INFLUXDB_INIT_ORG=ORG_NAME \
--env DOCKER_INFLUXDB_INIT_BUCKET=BUCKET_NAME \
influxdb:2
```
```
{{% /code-placeholders %}}
The command passes the following arguments:
The command passes the following arguments:
- `--publish 8086:8086`: Exposes the InfluxDB [UI](/influxdb/v2/get-started/#influxdb-user-interface-ui) and [HTTP API](/influxdb/v2/reference/api/) on the host's `8086` port.
- `--mount type=volume,source=influxdb2-data,target=/var/lib/influxdb2`: Creates a volume named `influxdb2-data` mapped to the [InfluxDB data directory](/influxdb/v2/reference/internals/file-system-layout/?t=docker#file-system-layout) to persist data outside the container.
- `--mount type=volume,source=influxdb2-config,target=/etc/influxdb2`: Creates a volume named `influxdb2-config` mapped to the [InfluxDB configuration directory](/influxdb/v2/reference/internals/file-system-layout/?t=docker#file-system-layout) to make configurations available outside the container.
- `-e DOCKER_INFLUXDB_INIT_MODE=setup`: Environment variable that invokes the automated setup of the initial organization, user, bucket, and token when creating the container.
- `-e DOCKER_INFLUXDB_INIT_<SETUP_OPTION>`: Environment variables for initial setup options--replace the following with your own values:
- `--publish 8086:8086`: Exposes the InfluxDB
[UI](/influxdb/v2/get-started/#influxdb-user-interface-ui) and
[HTTP API](/influxdb/v2/reference/api/) on the host's `8086` port.
to make configurations available outside the container.
- `--env DOCKER_INFLUXDB_INIT_MODE=setup`: Environment variable that invokes the
automated setup of the initial organization, user, bucket, and token when creating the container.
- `--env DOCKER_INFLUXDB_INIT_<SETUP_OPTION>`: Environment variables for initial
setup options--replace the following with your own values:
- {{% code-placeholder-key %}}`ADMIN_USERNAME`{{% /code-placeholder-key %}}: The username for the initial [user](/influxdb/v2/admin/users/)--an admin user with an API [Operator token](/influxdb/v2/admin/tokens/#operator-token).
- {{% code-placeholder-key %}}`ADMIN_PASSWORD`{{% /code-placeholder-key %}}: The password for the initial [user](/influxdb/v2/admin/users/).
- {{% code-placeholder-key %}}`ORG_NAME`{{% /code-placeholder-key %}}: The name for the initial [organization](/influxdb/v2/admin/organizations/).
- {{% code-placeholder-key %}}`BUCKET_NAME`{{% /code-placeholder-key %}}: The name for the initial [bucket](/influxdb/v2/admin/buckets/).
For more options, see the [`influxdb` Docker Hub image](https://hub.docker.com/_/influxdb) documentation.
_If you don't specify InfluxDB initial setup options, you can [set up manually](#set-up-influxdb) later using the UI or CLI in a running container._
The name for the initial [bucket](/influxdb/v2/admin/buckets/).
If successful, the command starts InfluxDB initialized with the user, organization, bucket,
and _[Operator token](/influxdb/v2/admin/tokens/#operator-token)_, and logs to stdout.
You can view the Operator token in the `/etc/influxdb2/influx-configs` file and use it to authorize [creating an All Access token](#optional-create-all-access-tokens).
_To run the InfluxDB container in [detached mode](https://docs.docker.com/engine/reference/run/#detached-vs-foreground),
include the `--detach` flag in the `docker run` command._
You can view the Operator token in the `/etc/influxdb2/influx-configs` file and
use it to authorize
[creating an All Access token](#optional-create-all-access-tokens).
include the `--detach` flag in the `docker run` command._
For more InfluxDB configuration options,
see the [`influxdb` Docker Hub image](https://hub.docker.com/_/influxdb)
documentation.
### Run InfluxDB CLI commands in a container
When you start a container using the `influxdb` Docker Hub image, it also installs the [`influx` CLI](/influxdb/v2/tools/influx-cli/) in the container.
With InfluxDB setup and running in the container, you can use the Docker CLI [`docker exec`](https://docs.docker.com/reference/cli/docker/container/exec/) command to interact with the `influx` and `influxd` CLIs inside the container.
When you start a container using the `influxdb` Docker Hub image, it also
installs the [`influx` CLI](/influxdb/v2/tools/influx-cli/) in the container.
With InfluxDB setup and running in the container, you can use the Docker CLI
To copy files, such as the InfluxDB server `config.yml` file, between your local file system and a volume, use the [`docker container cp` command](https://docs.docker.com/reference/cli/docker/container/cp/).
To copy files, such as the InfluxDB server `config.yml` file, between your local