Commands that helped resolve errors in Docker

Introduction

I will leave a memorandum of commands that were useful in building the Docker environment. It is recommended when you have created it but the error cannot be resolved.

Stop and delete containers

Stop container

Container confirmation


$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
797b4265f3d2        try_web             "/bin/sh -c 'rm -f t…"   24 minutes ago      Up 23 minutes       0.0.0.0:3000->3000/tcp              try_web_1

Specify the CONTAINER ID.

Container stop


$ sudo docker stop 797b4265f3d2
$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES

Delete container

Since it just stopped, we will also delete it.

Container confirmation


$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
797b4265f3d2        try_web             "/bin/sh -c 'rm -f t…"   24 minutes ago      Up 23 minutes       0.0.0.0:3000->3000/tcp              try_web_1

Specify the CONTAINER ID.

Delete container


$ sudo docker rm 797b4265f3d2
$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES

Delete image

I deleted the container, but the image remains.

Confirm image


$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
try_web             latest              c0ee642ca6bd        About an hour ago   1.01GB

Specify the IMAGE ID.

Delete image


$ sudo docker rmi c0ee642ca6bd
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

docker-compose exec app rails db: create error

In my case, I got an Access denied for user error, so I checked mysql. #After mysql-u root -Write p and log in to mysql.

Terminal


$ docker-compose up -d
$ docker-compose exec db bash
root@e5504121a08b:/# mysql -u root -p

If you want to exit, write exit.

Because the password was wrong here docker-compose exec app rails db:create I was getting the error.

Summary

This is just an example, and I think there are still useful commands. I hope it helps someone who is in the same situation as me.

Also, on twitter, technologies and ideas that are not uploaded to Qiita are also uploaded, so I would be grateful if you could follow me. Click here for details https://twitter.com/japwork

Recommended Posts

Commands that helped resolve errors in Docker
A solution to Docker errors that beginners tend to get stuck in
Edit Mysql with commands in Docker environment
Show Better Errors in Rails + Docker environment
Dealing with composer installation errors in Docker
How to resolve errors that occur in the "Ruby on Rails" integration test
Docker basic commands
Docker in LXD
Summary of frequently used commands in Rails and Docker
Docker terms and commands
Docker Frequently used commands
Ping commands in Java
List of Docker commands that I often use (container operation)
[Docker] List of errors that occurred when building the environment
[Docker] The story that an error occurred in docker-compose up