# Ubuntu

## 透過系統內建套件安裝

Ubuntu 14.04 版本套件庫中已經內建了 Docker 套件，可以直接安裝。

```bash
$ sudo apt-get update
$ sudo apt-get install -y docker.io
$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
$ sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker
```

如果使用作業系統內建套件安裝 Docker，目前安裝的版本是比較舊的 0.9.1。 要安裝更新的版本，可以透過更新 Docker 套件庫的方式進行安裝。

## 透過Docker 套件庫安裝最新版本

要安裝最新的 Docker 版本，首先需要安裝 apt-transport-https 支援，之後透過新增套件庫來安裝。

```bash
$ sudo apt-get install apt-transport-https
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo bash -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update
$ sudo apt-get install -y lxc-docker
```

## 快速安裝法(建議使用)

```bash
$ curl -sSL https://get.docker.com/ubuntu/ | sudo sh
```

## 14.04 之前版本

如果是較舊版本的 Ubuntu 系統，需要先更新核心。

```bash
$ sudo apt-get update
$ sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
$ sudo reboot
```

然後重複上面的步驟即可。

安裝之後啟動 Docker 服務。

```bash
$ sudo service docker start
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://philipzheng.gitbook.io/docker_practice/install/ubuntu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
