インストールされているか確認
$ docker --version
Docker version 20.10.7, build f0df350
$ docker-compose --version
docker-compose version 1.17.1, build unknown
build
$ sudo docker build -t appname:latest .
$ sudo docker-compose up -d
docker-composeでエラー発生
$ sudo docker-compose up -d
ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
versionを指定してインストールし直した
$ sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ sudo docker-compose --version
docker-compose version 1.22.0, build f46880fe
コンテナ起動を確認
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c2ce238f6df nginx:1.17.7 "nginx -g 'daemon of…" 11 seconds ago Up 10 seconds 0.0.0.0:80->80/tcp, :::80->80/tcp nginx
88e4dbc3754e appname:latest "gunicorn config.wsg…" 12 seconds ago Up 10 seconds appname
ログを確認
$ sudo docker logs -f appname
[2021-06-14 10:37:38 +0000] [1] [INFO] Starting gunicorn 20.1.0
[2021-06-14 10:37:38 +0000] [1] [INFO] Listening at: unix:/var/run/appname/appname.sock (1)
[2021-06-14 10:37:38 +0000] [1] [INFO] Using worker: sync
[2021-06-14 10:37:38 +0000] [8] [INFO] Booting worker with pid: 8