After graduating from Le Wagon Tokyo (https://www.lewagon.com/ja/tokyo), an English programming school from France that mainly teaches Ruby and Rails, I started studying Docker. I built Docker on a project I worked on after graduation, but I faced many errors. I solved the error by self-education through trial and error, so it took a lot of time. I think there are many people like me who have had trouble with errors when they first touch Docker, so I decided to write this article, hoping that the solution I used would be helpful.
1 PermissionError (Permission denied :‘~~~/your_app/tmp/db’) As far as I can see from the official Docker documentation, this error seems to be for Linux users only, but I'll share Permission as it can be annoying for Linux users. This error occurs because Docker creates a temporary database (db folder), but the currently logged in Linux user does not have the right to use that database.
First, use this command to move to that temporary folder.
$ cd ~~~(Path to your app)/(Your own app name)/tmp
Check which users can use the db folder with the following command.
$ ls -la
If you don't see the name of the currently logged-in Linux user, give that user permission with the following command:
$ sudo chown -R (Linux user name) .
password for (Linux user name):
Since it is a sudo command, you will be prompted to enter the password. At this point, you should be able to run major Docker commands such as "docker-compose build" and "docker-compose up" without any problems.
note: With a similar error, I said "FATAL: could not open file" I often see the error "global / pg_filenode.map": Permission denied ", but this is okay if you restart with" docker-compose stop "→" docker-compose up ".
2 No space left on your device This error occurs when the capacity of the Docker image becomes large due to the setting of Dockerfile. Unnecessary images and containers can be easily deleted with the following command.
$ docker image prune
$ docker container prune
When you enter these commands, you will see the following message:
WARNING! This will remove all dangling images (Or containers).
Are you sure you want to continue? [y/N]
Enter "y" because dangling images means unnecessary images. You should have enough space to run the same major Docker commands as when resolving a PermissionError.
If you need to remove more, look for the image you want to remove below.
$ docker images
After confirming the ID of the image you want to erase, delete it below.
$ docker image rm -f (ID of the image you want to erase)
Although in English, this book is recommended as it discusses in great detail how to use Docker in Ruby on Rails projects.
Docker for Rails Developers: https://pragprog.com/titles/ridocker/
Unfortunately, there are few Docker materials for Rails including English, so if you have a short history of Rails and want to read easy materials about Docker, it is English, but it is worth reading. think.
I wrote an article in English on Medium in more detail on this subject, so please take a look there as well.
https://medium.com/@shogohida_81081/5-solutions-to-common-errors-of-docker-for-beginners-c04dc1237c78
Recommended Posts