LoginSignup
3
3

More than 5 years have passed since last update.

Docker環境構築で発生したエラーと対処法メモ

Posted at

こんにちは、けんぞうです。
現在作成しているアプリでDocker環境を構築しているのですが、その中で発生したエラーと解消方法をまとめます。

(独学の範囲内ですので間違い等あればフィードバック頂けますと幸いです🙇‍♂️)

Version in "./docker-compose.yml" is unsupported

docker-compose upを再度実行しようとした際に発生したエラーです。こちらを参考にして解消しました。

#docker-composeの場所を特定する
$which docker-compose
/usr/local/bin/docker-compose

#一度docker-composeを削除する
$sudo rm /usr/local/bin/docker-compose

#upgradeする
$curl -L https://github.com/docker/compose/releases/download/1.20.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

$chmod +x /usr/local/bin/docker-compose

A server is already running. Check /myproject/tmp/pids/server.pid.

エラーではないのですが、docker-compose upを実行してもlocalhost:3000で立ち上がりを確認できない時の対処方法です。

結論としてはtmp/pids/server.pid.を削除で解決します。

毎回この事象が発生しないための対処法は以下の通りです。

①entrypoint.shを作成

entrypoint.sh
set -e

# Remove a potentially pre-existing server.pid for Rails.
rm -f /myproject/tmp/pids/server.pid

# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"

②Dockerfileに追記

Dockerfile
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3