# Better Stack Docker logging

## Start logging in 2 minutes

Collect logs and metrics from your Docker containers using Vector.

[vector-select-platform]

[vector-platform linux]
### 1. Setup
[/vector-platform]

[vector-platform linux-apt]
Install and configure [Vector](https://vector.dev/) on Ubuntu or Debian:
[/vector-platform]
[vector-platform linux-yum]
Install and configure [Vector](https://vector.dev/) on any Red Hat-based Linux:
[/vector-platform]
[vector-platform macos]
Install and configure [Vector](https://vector.dev/) on macOS:
[/vector-platform]
[vector-platform setup-script-supported]
```bash
[label Set up Vector]
curl -sSL https://telemetry.betterstack.com/setup-vector/docker/$SOURCE_TOKEN \
  -o /tmp/setup-vector.sh && \
  bash /tmp/setup-vector.sh
```

[info]
**Curious about what the script does?**

- Installs Vector using official package.
- Configures Vector for your Better Stack source.
- Enables and restarts Vector.

The script will ask for confirmation before making any changes.
[/info]

[/vector-platform]

[vector-platform windows]
#### Install

Install [Vector](https://vector.dev/docs/setup/installation/operating-systems/windows/) on Windows using official installer:

```powershell
[label Install Vector]
powershell Invoke-WebRequest https://packages.timber.io/vector/latest/vector-x64.msi -OutFile vector-latest-x64.msi
msiexec /i vector-latest-x64.msi
```


#### Setup

Run in Powershell as administrator to download Vector config:

```powershell
[label Download Vector config using Powershell]
$config_yaml_path = "C:\Program Files\Vector\config\vector.yaml"
$backup_path = "C:\Program Files\Vector\config\vector-backup.yaml"
Move-Item -Path "$config_yaml_path" -Destination "$backup_path"
Invoke-RestMethod -Uri https://telemetry.betterstack.com/vector-yaml/docker/$SOURCE_TOKEN |
  Add-Content $config_yaml_path
```


#### Run Vector

Run Vector with new configuration:

```powershell
[label Start Vector]
& "C:\Program Files\Vector\bin\vector" --config "C:\Program Files\Vector\config\vector.yaml"
```


[/vector-platform]
[vector-platform linux-other]
#### Install

Install [Vector](https://vector.dev/docs/setup/installation/manual/vector-installer/) using official installer:

```sh
[label Install Vector]
curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | sh -s -- -y
```

Create a [Vector service](https://www.shubhamdipt.com/blog/how-to-create-a-systemd-service-in-linux/):

```sh
[label Create a Vector service]
mkdir -p /etc/vector
mkdir -p /var/lib/vector/
cat <<-'SERVICE' >> /etc/systemd/system/vector.service
[Unit]
Description=Vector
Documentation=https://vector.dev
After=network-online.target
Requires=network-online.target

[Service]
User=vector
Group=vector
ExecStart=/root/.vector/bin/vector
ExecReload=/bin/kill -HUP $MAINPID
Restart=no
AmbientCapabilities=CAP_NET_BIND_SERVICE
EnvironmentFile=-/etc/default/vector

[Install]
WantedBy=multi-user.target
SERVICE
```


#### Setup

Download Vector configuration for your source:

```bash
[label Download Vector config]
CONFIG_YAML_PATH="/etc/vector/vector.yaml"
BACKUP_SUFFIX=".bak-$(date +%Y%m%d%H%M%S)"
mv "${CONFIG_YAML_PATH}" "${CONFIG_YAML_PATH}${BACKUP_SUFFIX}"
curl -o "$CONFIG_YAML_PATH" \
  https://telemetry.betterstack.com/vector-yaml/docker/$SOURCE_TOKEN
```


#### Restart Vector

Restart Vector to reload the configuration:

```sh
[label Restart Vector]
systemctl restart vector
```

[/vector-platform]


### 2. Grant permissions

Allow Vector to access Docker logs:

```bash
[label Grant Vector permissions]
usermod -a -G docker vector
```
 
You should see your logs in [Better Stack → Live tail](https://telemetry.betterstack.com/team/0/tail ";_blank").

Check out your metrics in the [Docker dashboard](https://telemetry.betterstack.com/team/0/dashboards/platform/docker ";_blank").

[info]
#### No logs coming in?
Make sure that Vector has all necessary permissions. Run `usermod -aG docker vector && service vector restart` to add `Vector` user to the `docker` group and restart Vector right away. 
[/info]

## Need help?

Please let us know at hello@betterstack.com.  
We're happy to help! 🙏


## Additional information

- Want to learn more about **production log management** for containers and daemon logs?
Check out our [comprehensive Docker logging tutorial](https://betterstack.com/community/guides/logging/how-to-start-logging-with-docker/).


- **Looking for manual instructions to set up Vector?**  
Find step-by-step instructions in our [dedicated Vector guide](https://betterstack.com/docs/logs/vector/#set-up-vector-manually).