# Docker

> Learn how to integrate the CLI with Docker.

First, [Download Docker], then run Docker Desktop and wait for Docker to finish initializing.

Then, create a new directory with a new file `dockerfile`.

CLI `dockerfile` example:

```bash
# Docker image
FROM ubuntu:latest
# Update and get dependency packages
RUN apt-get update && apt-get install -y curl libicu-dev
# Download and install the UGS CLI
RUN curl -L -o /usr/local/bin/ugs https://github.com/Unity-Technologies/unity-gaming-services-cli/releases/latest/download/ugs-linux-x64 \
    && chmod +x /usr/local/bin/ugs
ENTRYPOINT ["ugs"]
```

Build the image:

```bash
docker build --no-cache -t ugs-cli <path-to-new-directory> -f <path-to-new-dockerfile>
```

Pass your project ID and service account credentials as environment variables when you run a command, so they're never stored in the image:

```bash
docker run --rm -e UGS_CLI_PROJECT_ID -e UGS_CLI_SERVICE_KEY_ID -e UGS_CLI_SERVICE_SECRET_KEY ugs-cli status
docker run --rm -e UGS_CLI_PROJECT_ID -e UGS_CLI_SERVICE_KEY_ID -e UGS_CLI_SERVICE_SECRET_KEY \
    -v "$PWD":/work -w /work ugs-cli deploy <directory-with-service-configurations> -j
```

[Download Docker]: https://www.docker.com/products/docker-desktop/
