|
| 1 | +# Get started with Coder |
| 2 | + |
| 3 | +<div style="padding: 0px; margin: 0px;"> |
| 4 | + <span style="vertical-align:middle;">Author: </span> |
| 5 | + <a href="https://github.com/EdwardAngert" style="text-decoration: none; color: inherit; margin-bottom: 0px;"> |
| 6 | + <span style="vertical-align:middle;">Edward Angert</span> |
| 7 | + <img src="https://avatars.githubusercontent.com/u/17991901?v=4" width="24px" height="24px" style="vertical-align:middle; margin: 0px;"/> |
| 8 | + </a> |
| 9 | +</div> |
| 10 | +August 18, 2024 |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +Follow the steps in this guide to install Coder locally or on a device on your |
| 15 | +network, set up a workspace, and connect to it from VS Code. |
| 16 | + |
| 17 | +By the end of this guide, you'll have a remote development environment that you |
| 18 | +can connect to from any device anywhere, so you can work on the same files in a |
| 19 | +persistent environment from your main device, a tablet, or your phone. |
| 20 | + |
| 21 | +## Install and start Coder |
| 22 | + |
| 23 | +<div class="tabs"> |
| 24 | + |
| 25 | +## Linux/macOS |
| 26 | + |
| 27 | +1. Install Docker: |
| 28 | + |
| 29 | + ```bash |
| 30 | + curl -sSL https://get.docker.com | sh |
| 31 | + ``` |
| 32 | + |
| 33 | + For more details, visit: |
| 34 | + |
| 35 | + - [Linux instructions](https://docs.docker.com/desktop/install/linux-install/) |
| 36 | + - [Mac instructions](https://docs.docker.com/desktop/install/mac-install/) |
| 37 | + |
| 38 | +1. Set up the Docker daemon in rootless mode for your user to run Docker as a |
| 39 | +non-privileged user: |
| 40 | + |
| 41 | + ```shell |
| 42 | + dockerd-rootless-setuptool.sh install |
| 43 | + ``` |
| 44 | + |
| 45 | + Depending on your system's dependencies, you might need to run other |
| 46 | + commands before you retry this step. |
| 47 | + Read the output of this command for further instructions. |
| 48 | + |
| 49 | +1. Assign your user to the Docker group: |
| 50 | + |
| 51 | + ```shell |
| 52 | + sudo usermod -aG docker $USER |
| 53 | + ``` |
| 54 | + |
| 55 | +1. Install Coder: |
| 56 | + |
| 57 | + ```shell |
| 58 | + curl -L https://coder.com/install.sh | sh |
| 59 | + ``` |
| 60 | + |
| 61 | + - For standalone binaries, system packages, or other alternate installation |
| 62 | + methods, refer to the |
| 63 | + [latest release on GitHub](https://github.com/coder/coder/releases/latest). |
| 64 | + |
| 65 | +## Windows |
| 66 | + |
| 67 | +> **Important:** If you plan to use the built-in PostgreSQL database, |
| 68 | +> ensure that the |
| 69 | +> [Visual C++ Runtime](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist#latest-microsoft-visual-c-redistributable-version) |
| 70 | +> is installed. |
| 71 | +
|
| 72 | +1. [Install Docker](https://docs.docker.com/desktop/install/windows-install/). |
| 73 | + |
| 74 | +1. Download the Coder Windows installer (`.msi`) or standalone binary (`.exe`) |
| 75 | +from the [GitHub repository assets](https://github.com/coder/coder/releases/latest). |
| 76 | + |
| 77 | + _Windows setup wizard_ |
| 78 | + |
| 79 | + - Alternatively, you can use the |
| 80 | + [`winget`](https://learn.microsoft.com/en-us/windows/package-manager/winget/#use-winget) |
| 81 | + package manager to install Coder: |
| 82 | + |
| 83 | + ```powershell |
| 84 | + winget install Coder.Coder |
| 85 | + ``` |
| 86 | +
|
| 87 | +1. Start Coder: |
| 88 | +
|
| 89 | + ```shell |
| 90 | + coder server |
| 91 | + ``` |
| 92 | + |
| 93 | +</div> |
| 94 | + |
| 95 | +## Configure Coder with a new Workspace |
| 96 | + |
| 97 | +1. If you're running Coder locally, go to <http://0.0.0.0:3001/setup>. |
| 98 | + |
| 99 | + - If you get a browser warning similar to `Secure Site Not Available`, you |
| 100 | + can ignore the warning and continue to the setup page. |
| 101 | + |
| 102 | + If your Coder server is on a network or cloud device, locate the message in |
| 103 | + your terminal that reads, `View the Web UI: https://<CUSTOM-STRING>.<TUNNEL>.try.coder.app`. |
| 104 | + The server begins to stream logs immediately and you might have to scroll up to find it. |
| 105 | + |
| 106 | +1. On the **Welcome to Coder** page, enter the information to create an admin |
| 107 | +user, then select **Create account**. |
| 108 | + |
| 109 | + _Welcome to Coder - Create admin user_ |
| 110 | + |
| 111 | +1. On the Workspaces page, select **Go to templates** to create a new template. |
| 112 | + |
| 113 | +1. For this guide, use a Docker container. Locate **Docker Containers** and |
| 114 | +select **Use template**. |
| 115 | + |
| 116 | +1. Give the template a **Name** that you'll recognize both in the Coder UI and |
| 117 | +in command-line calls. |
| 118 | + |
| 119 | + The rest of the template details are optional, but will be helpful when you have more templates. |
| 120 | + |
| 121 | + _Create template_ |
| 122 | + |
| 123 | +1. Select **Create template**. |
| 124 | + |
| 125 | +1. After the template is ready, select **Create Workspace**. |
| 126 | + |
| 127 | +1. Give the workspace a name and select **Create Workspace**. |
| 128 | + |
| 129 | +1. Coder starts your new workspace: |
| 130 | + |
| 131 | + _getting-started-workspace is running_ |
| 132 | + |
| 133 | +1. Select **VS Code Desktop** to install the Coder extension and connect to |
| 134 | + your Coder workspace. |
| 135 | + |
| 136 | + <details><summary>Connect via SSH in VSCodium</summary> |
| 137 | + |
| 138 | + VSCodium doesn't use the Microsoft VS Code extension marketplace or application |
| 139 | + calls. |
| 140 | + Enable SSH connections to the Coder workspace Docker container and connect to |
| 141 | + it from VSCodium with the **Remote - SSH** extension. |
| 142 | + |
| 143 | + 1. In the workspace, select **Connect via SSH**. |
| 144 | + |
| 145 | + 1. Select the `ssh` command below **Connect to the agent** to copy the command. |
| 146 | + |
| 147 | + 1. Open a terminal window on the Coder server (or SSH to it if it's a device on your network). |
| 148 | + |
| 149 | + 1. Run the `ssh` command to connect to the agent. Replace `your-workspace-name` in this example: |
| 150 | + |
| 151 | + ```bash |
| 152 | + ssh coder.your-workspace-name.main |
| 153 | + ``` |
| 154 | + |
| 155 | + 1. Use the Web UI URL from [Configure Coder with a new workspace](#configure-coder-with-a-new-workspace) to log in and authenticate: |
| 156 | + |
| 157 | + ```bash |
| 158 | + coder login https://<CUSTOM-STRING>.<TUNNEL>.try.coder.app |
| 159 | + ``` |
| 160 | + |
| 161 | + 1. Copy the session token, then paste it in the SSH session in the terminal. |
| 162 | + |
| 163 | + Note that, for security purposes, no characters will appear on the screen |
| 164 | + when you paste the token: |
| 165 | + |
| 166 | + ```plaintext |
| 167 | + > Paste your token here: |
| 168 | + > Welcome to Coder, user! You're authenticated. |
| 169 | + ``` |
| 170 | +
|
| 171 | + 1. Run the Coder SSH configuration and enter `yes` to continue: |
| 172 | +
|
| 173 | + ```console |
| 174 | + $ coder config-ssh |
| 175 | + Continue? (yes/no) yes |
| 176 | + ``` |
| 177 | +
|
| 178 | + 1. Install the [Remote - SSH extension](https://open-vsx.org/extension/jeanp413/open-remote-ssh). |
| 179 | +
|
| 180 | + 1. Select **Remote-SSH: Connect to host** from the command palette. |
| 181 | +
|
| 182 | + 1. Enter the SSH host: |
| 183 | +
|
| 184 | + 1. Enter your password: |
| 185 | +
|
| 186 | + </details> |
| 187 | +
|
| 188 | +## Work on some code |
| 189 | +
|
| 190 | +After VS Code loads the remote environment, you can select **Open Folder** to explore directories in the Docker container or work on something new. |
| 191 | +
|
| 192 | +To clone an existing repository: |
| 193 | +
|
| 194 | +1. Select **Clone Repository** and enter the repository URL. |
| 195 | +
|
| 196 | + For example, to clone the Coder repo, enter `https://github.com/coder/coder.git`. |
| 197 | +
|
| 198 | + Learn more about how to find the repository URL in the [GitHub documentation](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository). |
| 199 | +
|
| 200 | +1. Choose the folder to which VS Code should clone the repo. |
| 201 | +It will be in its own directory within this folder. |
| 202 | +
|
| 203 | + Note that you cannot create a new parent directory in this step. |
| 204 | +
|
| 205 | +1. After VS Code completes the clone, select **Open** to open the directory. |
| 206 | +
|
| 207 | +1. You are now using VS Code in your Coder environment! |
| 208 | +
|
| 209 | +## What's next? |
| 210 | +
|
| 211 | +Now that you have your own workspace, use the same template to set one up for a |
| 212 | +teammate. |
| 213 | +
|
| 214 | +Go to **Templates** and select **Create Workspace** and continue from Step 7 in [Configure Coder with a new workspace](#configure-coder-with-a-new-workspace). |
| 215 | +
|
| 216 | +After that, you can try to: |
| 217 | +
|
| 218 | +- [Customize templates](../templates/customizing) |
| 219 | +- [Enable Prometheus metrics](../admin/prometheus#enable-prometheus-metrics) |
| 220 | +- [Deploy to Google Cloud Platform (GCP)](../platforms/gcp) |
| 221 | +
|
| 222 | +## Troubleshooting |
| 223 | +
|
| 224 | +### Cannot connect to the Docker daemon |
| 225 | +
|
| 226 | +> Error: Error pinging Docker server: Cannot connect to the Docker daemon at |
| 227 | +> unix:///var/run/docker.sock. Is the docker daemon running? |
| 228 | +
|
| 229 | +1. Install Docker for your system: |
| 230 | +
|
| 231 | + ```shell |
| 232 | + curl -sSL https://get.docker.com | sh |
| 233 | + ``` |
| 234 | +
|
| 235 | +1. Set up the Docker daemon in rootless mode for your user to run Docker as a |
| 236 | +non-privileged user: |
| 237 | +
|
| 238 | + ```shell |
| 239 | + dockerd-rootless-setuptool.sh install |
| 240 | + ``` |
| 241 | +
|
| 242 | + Depending on your system's dependencies, you might need to run other |
| 243 | + commands before you retry this step. |
| 244 | + Read the output of this command for further instructions. |
| 245 | +
|
| 246 | +1. Assign your user to the Docker group: |
| 247 | +
|
| 248 | + ```shell |
| 249 | + sudo usermod -aG docker $USER |
| 250 | + ``` |
| 251 | +
|
| 252 | +1. Confirm that the user has been added: |
| 253 | +
|
| 254 | + ```console |
| 255 | + $ groups |
| 256 | + docker sudo users |
| 257 | + ``` |
| 258 | +
|
| 259 | + - Ubuntu users might not see the group membership update. In that case, run |
| 260 | + the following command or reboot the machine: |
| 261 | +
|
| 262 | + ```shell |
| 263 | + newgrp docker |
| 264 | + ``` |
| 265 | +
|
| 266 | +### Can't start Coder server: Address already in use |
| 267 | +
|
| 268 | +```shell |
| 269 | +Encountered an error running "coder server", see "coder server --help" for more information |
| 270 | +error: configure http(s): listen tcp 127.0.0.1:3000: bind: address already in use |
| 271 | +``` |
| 272 | +
|
| 273 | +1. Stop the process: |
| 274 | +
|
| 275 | + ```shell |
| 276 | + sudo systemctl stop coder |
| 277 | + ``` |
| 278 | +
|
| 279 | +1. Start Coder: |
| 280 | +
|
| 281 | + ```shell |
| 282 | + coder server |
| 283 | + ``` |
| 284 | +
|
| 285 | +1. |
0 commit comments