本文へスキップ

ガイド · VPS

Docker のインストール

公式スクリプトでインストール → compose で実行。

1. Install (Ubuntu · Debian)

curl -fsSL https://get.docker.com | sh
docker run --rm hello-world

Hello from Docker!confirms success. Rocky · CentOS: Docker installation docs.

2. Run with Compose

mkdir -p /root/web && cd /root/web → nano compose.yaml:

services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
    volumes:
      - ./html:/usr/share/nginx/html:ro
    restart: unless-stopped
ActionCommand
Start (background)docker compose up -d
Statusdocker compose ps
Logsdocker compose logs -f
Update imagedocker compose pull && docker compose up -d
Stopdocker compose down

Connect: http://PUBLIC_IP:8080.

3. Ports

  • "8080:80" = external 8080 → container 80. Only inbound TCP is supported.
  • Docker-published ports bypass ufw. To restrict them, use the store Firewall tab, or bind only inside the server: "127.0.0.1:8080:80".
  • Do not expose database containers (MySQL · PostgreSQL · Redis) to the internet.

4. Start after reboot

restart: unless-stoppedmakes the container start again after a server reboot. Docker itself is set to start at boot during installation.

5. Disk cleanup

ActionCommand
Usagedocker system df
Remove unused images and containersdocker system prune

If logs keep growing, configure /etc/docker/daemon.json:

{ "log-driver": "json-file", "log-opts": { "max-size": "10m", "max-file": "3" } }

systemctl restart docker applies this to newly created containers.

すべてのガイド VPS プラン お問い合わせ