Dockerをネットブックで動作させたい

ネットブックという10年以上前のPCを開発環境として使っています。

ネットブックのスペック

  • CPU:Atom N270(1コア/2スレッド)※32bit
  • メモリ:1GB
  • ストレージ:HDD 120GB

Dockerの公式サイトでは、32bitのCPUではDocker、docker-compose共に対象外になっています。
https://docs.docker.com/install/
https://docs.docker.com/compose/install/

このようなPCでも、ディストリビューションによってはDockerをパッケージより導入可能です。

ここでは「Ubuntu server 18.04 LTS」を用いて導入します。
※ディストリビューション自体の導入手順は省略します。
※導入当時のログがないため、参考サイトなどを元に記載しています。

$ sudo apt update
$ sudo apt install docker.io docker-compose

# sudoなしでdockerを実行できるようにします。
$ sudo usermod -aG docker $USER

# 一旦ログインし直します。

正常にインストールできているか、バージョンを確認してみます。(2020/04/05現在)

$ docker --version
Docker version 19.03.6, build 369ce74a3c

$ docker-compose --version
docker-compose version 1.17.1, build unknown

それぞれ、動作を確認してみます。
まずはDockerを確認します。

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
895e610a6b07: Pull complete 
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (i386)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

次に、docker-composeを確認します。

$ mkdir test
$ cd test
$ vim docker-compose.yml
version: '3.4'

services:
    nginx:
        image: i386/nginx
        ports:
            - 9080:80
$ docker-compose up -d
Creating test_nginx_1 ... 
Creating test_nginx_1 ... done

$ curl http://localhost:9080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

$ docker-compose ps
    Name             Command          State          Ports        
------------------------------------------------------------------
test_nginx_1   nginx -g daemon off;   Up      0.0.0.0:9080->80/tcp

動作可能なことが確認できました。

注意点

  • docker-composeのバージョンが低いため、docker-compose.ymlでバージョン指定する際には注意が必要です。
    ※2020/04/05時点では、ファイル側のバージョン指定は「3.4」まで可能です。
  • Docker imageを指定する場合は、i386アーキテクチャに対応しているか確認が必要です。
    • Docker HubではDockerの公式サポートではないですが、公式イメージより作成されたものが「i386/xxx」イメージとして提供されているようです。

参考サイト様