# Docker Engine/Docker Composeのインストール

**URL:** https://forum.ficusonline.com/t/topic/310
**Category:** Server
**Created:** [2019 年 6 月 18 日午前 6:10 UTC](https://forum.ficusonline.com/t/topic/310 "2019-06-18T06:10:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2019 年 6 月 18 日午前 6:10 UTC](https://forum.ficusonline.com/t/topic/310/1 "2019-06-18T06:10:22Z")

</div>

Docker公式レポジトリによりDocker Engine最新バージョンをインストール

[https://www.docker.com/](https://www.docker.com/)

> **[Install Docker Engine](https://docs.docker.com/engine/install/)**
>
> Learn how to choose the best method for you to install Docker Engine. This client-server application is available on Linux, Mac, Windows, and as a static binary.

**Ubuntu**

> **[Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/)**
>
> Jumpstart your client-side server applications with Docker Engine on Ubuntu. This guide details prerequisites and multiple methods to install Docker Engine on Ubuntu.

**1.パッケージアップデート**

```auto
$ sudo apt-get update

```

**2.以下関連パッケージのインストール**

```auto
$ sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

```

**3.Docker公式GPG公開キー追加**

```auto
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

```

**4.Docker Engineレポジトリ安定版追加**

```auto
$ echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

```

**5.Docker Engineインストール**

```auto
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

```

**6.Dockerイメージの動作確認**

```auto
$ sudo docker run hello-world

```

**7.ユーザレベルでの実行**

> **[Linux post-installation steps for Docker Engine](https://docs.docker.com/engine/install/linux-postinstall/)**
>
> Find the recommended Docker Engine post-installation steps for Linux users, including how to run Docker as a non-root user and more.

dockerグループにユーザを追加することでユーザレベルでdockerを実行できるようにします。

dockerグループを追加（多分既に存在しています）

```auto
$ sudo groupadd docker

```

現ユーザ（任意）をdockerグループに追加

```auto
$ sudo usermod -aG docker $USER

```

再ログインで有効

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 12 月 7 日午後 12:11 UTC](https://forum.ficusonline.com/t/topic/310/2 "2021-12-07T12:11:58Z")

</div>

## Docker Composeのインストール

> **[Install](https://docs.docker.com/compose/install/)**
>
> Learn how to install Docker Compose. Compose is available natively on Docker Desktop, as a Docker Engine plugin, and as a standalone tool.

**リリースバージョン**

> **[Releases · docker/compose](https://github.com/docker/compose/releases)**
>
> Define and run multi-container applications with Docker - docker/compose

## バージョン1のインストール

上記リリースされているバージョンのバイナリ（ **1.29.2** ）を`docke-compose`として `/usr/local/bin`ディレクトリへダウンロード

```auto
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

```

実行権を付与

```auto
$ sudo chmod +x /usr/local/bin/docker-compose

```

* * *

## バージョン2のインストール

Docker Engineのプラグインとしてバージョン2がリリース。

コマンドが `"docker-compose"` から `"docker compose"` へ変更

> **[Docker Compose](https://docs.docker.com/compose/)**
>
> Learn how to use Docker Compose to define and run multi-container applications with this detailed introduction to the tool.

### Install on Linux

You can install Compose V2 by downloading the appropriate binary for your system from the [project release page](https://github.com/docker/compose/releases) and copying it into `$HOME/.docker/cli-plugins` as `docker-compose`.

1. Run the following command to download the current stable release of Docker Compose:

```auto
 $ mkdir -p ~/.docker/cli-plugins/
 $ curl -SL https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose

```

This command installs Compose V2 for the active user under `$HOME` directory. To install Docker Compose for all users on your system, replace `~/.docker/cli-plugins` with `/usr/local/lib/docker/cli-plugins`.  
2. Apply executable permissions to the binary:

```auto
 $ chmod +x ~/.docker/cli-plugins/docker-compose

```

1. Test your installation

```auto
 $ docker compose version
 Docker Compose version 2.0.1

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 11 月 13 日午前 2:16 UTC](https://forum.ficusonline.com/t/topic/310/3 "2022-11-13T02:16:57Z")

</div>

## シェルスクリプトによるインストール (`Ubuntu`)

> **[Install using the convenience script - Ubuntu](https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script)**
>
> To get started with Docker Engine on Ubuntu, make sure you meet the prerequisites, and then follow the installation steps. | Jumpstart your client-side server applications with Docker Engine on Ubuntu. This guide details prerequisites and multiple...

上記 **`docker`** と **`docker compose`** のインストール作業は下記スクリプトでも実行できます（簡単推奨）。

```auto
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ DRY_RUN=1 sudo sh ./get-docker.sh

```

現ユーザ（任意）をdockerグループに追加（再ログインで有効）

```auto
$ sudo usermod -aG docker $USER

```

バージョン確認(`docker`)

```auto
$ docker version
Client: Docker Engine - Community
 Version: 20.10.21
 API version: 1.41
 Go version: go1.18.7
 Git commit: baeda1f
 Built: Tue Oct 25 18:01:58 2022
 OS/Arch: linux/amd64
 Context: default
 Experimental: true

Server: Docker Engine - Community
 Engine:
  Version: 20.10.21
  API version: 1.41 (minimum version 1.12)
  Go version: go1.18.7
  Git commit: 3056208
  Built: Tue Oct 25 17:59:49 2022
  OS/Arch: linux/amd64
  Experimental: false
 containerd:
  Version: 1.6.9
  GitCommit: 1c90a442489720eec95342e1789ee8a5e1b9536f
 runc:
  Version: 1.1.4
  GitCommit: v1.1.4-0-g5fd4c4d
 docker-init:
  Version: 0.19.0
  GitCommit: de40ad0

```

バージョン確認(`docker compose`)

```auto
$ docker compose version
Docker Compose version v2.12.2

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2023 年 4 月 4 日午後 1:32 UTC](https://forum.ficusonline.com/t/topic/310/4 "2023-04-04T13:32:45Z")

</div>

## Docker in Docker

[https://github.com/nestybox/sysbox](https://github.com/nestybox/sysbox)
