A solution to Docker errors that beginners tend to get stuck in

Article background

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)

References

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.

Medium English Articles

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

A solution to Docker errors that beginners tend to get stuck in
Get stuck in a Java primer
What to do if you get a gcc error in Docker
Commands that helped resolve errors in Docker
[AWS CLI] Switch roles to get a Docker image in another account
How to get a heapdump from a Docker container
A story that got stuck with an error during migration in docker PHP laravel
About the solution of the error that occurred when trying to create a Japanese file of devise in the Docker development environment
Spring boot Things that beginners tend to have (@ComponentScan)
Fargate to get a rough idea in relation to EC2
With podman in docker, everyone wants to get along and use docker on a shared computer
What to do if you get a java.io.IOException in GlassFish
Solution for errors that occur when upgrading to Rails 5.2 series
A funny story stuck in a mess when trying to import fx-clj
How to implement a job that uses Java API in JobScheduler
A little happy that Nginx's Docker container defaults to graceful shutdown
I'm stuck trying to get my own annotations working in Eclipse
How to run a job with docker login in AWS batch
What to do if you get a DISPLAY error in gym.render ()
I got stuck trying to write a where in clause in ActiveRecord
A story stuck with log output in Docker + Play framework environment
How to get JDK 11 on your mac in a comfortable way
To beginners launching Docker on AWS
How to get parameters in Spark
How to test a private method in Java and partially mock that method
What to do if you get a groovy warning in Thymeleaf Layout
How to quickly create a reverse proxy that supports HTTPS with Docker
How to build a Ruby on Rails environment using Docker (for Docker beginners)
A shell script that builds a Docker image and pushes it to ECR
I tried to build a Firebase application development environment with Docker in 2020
How to get the current date as a string in yyyyMMdd format
How to get the absolute path of a directory running in Java
How to migrate a web application created in a local docker environment to AWS
[Java] [For beginners] How to insert elements directly in a 2D array
[Ruby / Rails] Use alias. In a way that rubocop won't get angry!
How to start a Docker container with a volume mounted in a batch file
How to apply Rails environment variables to Docker container (aws :: Sigv4 :: Errors solution)