0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[ROS] WARNING: cannot create log directory への対処

Last updated at Posted at 2023-10-29

はじめに

最近、業務でRosとDockerの連携をやりはじめましたが、中々同じ問題にあったている人がいなかったので、ここで共有しようと思います。ちなみにDocker初心者です。。

問題

Dockerで.ros/logをバインドマウントをしていたのですが、rosclean直後にコンテナを立ち上げてしまい、roscoreが立ち上がらなくなりました。

$ roscore
WARNING: cannot create log directory [/home/username/.ros/log/logdir]. Please set ROS_LOG_DIR to a writable location.
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

解決策

結論から言うと、以下のコマンドで解決します。基本usernameとgroupnameは一緒です。

$ sudo chown -R username:groupname /home/username/.ros/log

原因

Dockerでバインドマウントの対象のディレクトリがホストマシン側に存在しない場合、コンテナを立ち上げるとそのディレクトリがホストマシン上に自動的に作成されるそうです。そのため、roscleanを実行した直後は.ros/logディレクトリは存在しないので、コンテナを立ち上げる際にこのディレクトリも作成されます。

ここで問題が生じるのは、このディレクトリ内のファイルの所有者が作成者であるコンテナのユーザーになる点です。そのため、ホストマシン側でroscoreを立ち上げようとしても、権限がなくlogディレクトリを作成できないために立ち上がりません。

終わりに

今回みたいな問題に当たるとLinuxの仕組みを理解する機会にもなって面白かったです。「ワタシハリナックスチョットデキル」ようになりたいです...笑

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?