Skip to content

Commit

Permalink
Merge pull request #8 from thin-edge/docs-add-networking-notes
Browse files Browse the repository at this point in the history
docs: add notes about docker network
  • Loading branch information
reubenmiller authored Sep 10, 2024
2 parents 53299ed + 116b0f3 commit 1520bc6
Showing 1 changed file with 51 additions and 9 deletions.
60 changes: 51 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,81 @@ Before you can start the containers, you need to create a device certificate ins
docker volume create device-certs
```

2. Create a new device certificate
2. Set the Cumulocity IoT variable (to make it easier to copy/paste the remaining instructions)

```sh
TEDGE_C8Y_URL="${C8Y_DOMAIN}"
```

3. Create a new device certificate

```sh
docker run --rm -it \
-v "device-certs:/etc/tedge/device-certs" \
-e "TEDGE_C8Y_URL=${C8Y_DOMAIN}" \
ghcr.io/thin-edge/tedge-main:latest tedge cert create --device-id "<mydeviceid>"
-e "TEDGE_C8Y_URL=${TEDGE_C8Y_URL}" \
ghcr.io/thin-edge/tedge-container-bundle:latest tedge cert create --device-id "<mydeviceid>"
```

3. Upload the device certificate to Cumulocity IoT
4. Upload the device certificate to Cumulocity IoT

```sh
docker run --rm -it \
-v "device-certs:/etc/tedge/device-certs" \
-e "TEDGE_C8Y_URL=$C8Y_DOMAIN" \
-e "C8Y_USER=$C8Y_USER" \
-e "C8Y_PASSWORD=$C8Y_PASSWORD" \
ghcr.io/thin-edge/tedge-main:latest tedge cert upload c8y
-e "TEDGE_C8Y_URL=$TEDGE_C8Y_URL" \
ghcr.io/thin-edge/tedge-container-bundle:latest tedge cert upload c8y
```

If you are having problems with the docker network, you can try to use the host network and explicitly set a DNS address:

```sh
docker run --rm -it --dns 8.8.8.8 --network host \
-v "device-certs:/etc/tedge/device-certs" \
-e "TEDGE_C8Y_URL=${TEDGE_C8Y_URL}" \
ghcr.io/thin-edge/tedge-container-bundle:latest tedge cert upload c8y
```

**Tip**

If you don't want to be prompted for the Cumulocity IoT Username and Password (required to upload the certificate), then you can provide them via the following environment variables:
```sh
docker run --rm -it --dns 8.8.8.8 --network host \
-v "device-certs:/etc/tedge/device-certs" \
-e "TEDGE_C8Y_URL=${TEDGE_C8Y_URL}" \
-e "C8Y_USER=$C8Y_USER" \
-e "C8Y_PASSWORD=$C8Y_PASSWORD" \
ghcr.io/thin-edge/tedge-container-bundle:latest tedge cert upload c8y
```
### Step 2: Start thin-edge.io
Once the device certificate has been created inside the named volume, the same volume can be used when starting the container.
```sh
docker run --rm -it \
docker run --rm -it --dns 8.8.8.8 --network host \
-v "device-certs:/etc/tedge/device-certs" \
-e "TEDGE_C8Y_URL=$C8Y_DOMAIN" \
ghcr.io/thin-edge/tedge-container-bundle:latest
```
The `TEDGE_C8Y_URL` env variable is used to set the target Cumulocity IoT so that thin-edge.io knows where to connect to.
All of the thin-edge.io settings can be customized via environment variables, which can be useful if you want to change the port numbers like in the following example:
```sh
docker run --rm -it --dns 8.8.8.8 --network host \
-d \
-v "device-certs:/etc/tedge/device-certs" \
-e TEDGE_C8Y_PROXY_BIND_PORT=9001 \
-e TEDGE_C8Y_PROXY_CLIENT_PORT=9001 \
-e TEDGE_MQTT_BIND_PORT=1884 \
-e TEDGE_MQTT_CLIENT_PORT=1884 \
-e TEDGE_HTTP_BIND_PORT=9000 \
-e TEDGE_HTTP_CLIENT_PORT=9000 \
-e "TEDGE_C8Y_URL=$TEDGE_C8Y_URL" \
ghcr.io/thin-edge/tedge-container-bundle:latest
```
### Development
#### Starting the container
Expand Down

1 comment on commit 1520bc6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
6 0 1 6 100 12.797103s

Passed Tests

Name ⏱️ Duration Suite
Get Logfile Request 2.347 s Operations
Get Configuration File 4.653 s Operations
Execute Shell Command 3.042 s Operations
Cloud Connecion is Online 0.115 s Telemetry
Service status 0.213 s Telemetry
Sends measurements 2.425 s Telemetry

Please sign in to comment.